site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com The four commands in use: SHM_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK a code fragment: [...] struct shmid_ds shm_info; max_id = shmctl( 0, SHM_INFO, &shm_info ); if (max_id >= 0) { for ( int i = 0; (_memptr == NULL) && (i <= max_id); ++i ) { shm_id = shmctl( i, SHM_STAT, &shm_segment ); if ( shm_id < 0 ) continue; [...] or: [...] if (swapable) { shmctl(__shared_mem_id, SHM_UNLOCK, NULL); } else { shmctl(__shared_mem_id, SHM_LOCK, NULL); } [...] Use standard APIs instead: <http://www.opengroup.org/onlinepubs/009695399/functions/shmctl.html> ? -- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Mar 31, 2008, at 11:23 AM, Christof Rath wrote: Hey there, I try to compile a robot framework that is written for Linux. My problem is, that it uses shmctl() commands that aren't defined in shm.h (like on linux systems). is there a workaround? Can anybody tell me how to access this information? SHM_INFO you can emulate by writing code to popen the "ipcs" command. You are better off using ftok(0 to identify a shared memory segment key specifically, rather than trying to figure out the next available one. SHM_STAT does not appear to be a useful API, since it only returns an array index, and that array index could in no way be useful to you directly, since you can't access the array which is being indexed by the number which would be returned. SHM_LOCK/SHM_UNLOCK are really dangerous, since you are asking that the memory region be wired down. You can ask for this via the standard interfaces mlock() and munlock(). Typically, this is a bad idea. Wiring down physical memory is constrained by administrative limits which can not be bypassed, so if you ask for too much, you will get none. These interfaces work equally well in Linux, and are more portable. This email sent to site_archiver@lists.apple.com
participants (1)
-
Terry Lambert