mmap() on 64 bit m/c


 
Thread Tools Search this Thread
Operating Systems Solaris mmap() on 64 bit m/c
# 1  
Old 05-20-2009
mmap() on 64 bit m/c

Dear Experts,

i have a problem related to mmap(), when i run my program on sun for 64 bit which is throwing SIGBUS when it encounters mmap() function, what is the reason how to resolve this one, because it is working for 32 bit.

with regards,
vidya.
# 2  
Old 05-20-2009
Can have the scrrenshot with the error that you see exactly?
# 3  
Old 05-26-2009
Sigbus with mmap.

sorry for the delayed reply,
please help me i am trying like this, though this is one sample test,
iam opening the two files one for reading and one for writing, and i am checking like this
Code:
if((input = open(argv[1], O_RDONLY)) == -1)
  fprintf(stderr, "%s: Error: opening file: %s\n", PACKAGE, argv[1]), exit(1);

 if((output = open(argv[2], O_RDWR|O_CREAT|O_TRUNC, 0666)) == -1)
  fprintf(stderr, "%s: Error: opening file: %s\n", PACKAGE, argv[2]), exit(1);

   source = (char *)mmap((char *)0, filesize, PROT_READ, MAP_SHARED,   input, 0);
printf("\n address of source==%p",source);
 if(source[0] ==-1)
  fprintf(stderr, "Error mapping input file: %s\n", argv[1]), exit(1);

target =(char *) mmap((char  *)0, filesize, PROT_WRITE, MAP_SHARED, output, 0);

printf("\n address of target==%d",target);
 if(target[0]==-1) //problem here
  fprintf(stderr, "Error mapping ouput file: %s\n", argv[2]), exit(1);

as i am opening both of them and checking instead of MAP_FAILED for the failure to target[0]==-1 ,
my question is what exactly is the data structure that mmap returns when i test for read it is successfull and for write it is not and also
if i change that to
if(target==(void*)-1 ) it returns successfull,
because in my code they have used
target[0]==-1 which is failing and results in sigbus if i replace it with
if(target==MAP_FAILED)
it is not even going for failure nor the sucess,
and fails some where in the reading. so what is the reason of sigbus
please solve my problem
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Which version of Windows Vista to install with a product key? 32-bit or 64-bit?

Hello everyone. I bought a dell laptop (XPS M1330) online which came without a hard drive. There is a Windows Vista Ultimate OEMAct sticker with product key at the bottom case. I checked dell website (here) for this model and it says this model supports both 32 and 64-bit version of Windows... (4 Replies)
Discussion started by: milhan
4 Replies

2. Shell Programming and Scripting

How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H

Hi, Here is the issue. From the program snippet I have Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF which are of 40 and 56 bits. SO I used use bignum to do the math but summing them up I always failed having correct result. perl interpreter info, perl, v5.8.8 built for... (0 Replies)
Discussion started by: rrd1986
0 Replies

3. UNIX for Advanced & Expert Users

migrating unix mp-ras 32 bit to linux suse 64 bit

Hi. I need to migrate the whole unix environment from a Unix mp-ras 32 bit to a Linux Suse 64 bit. 1) can i use cpio to copy the data? 2) can i just copy the users from unix to linux or do i have to create them by hand 3) are there any other concerns i should worry about? thanx (1 Reply)
Discussion started by: mrodrig
1 Replies

4. Programming

copying or concatinating string from 1st bit, leaving 0th bit

Hello, If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit. How do i do it? (2 Replies)
Discussion started by: jazz
2 Replies
Login or Register to Ask a Question