1################################################################################ 2# 3# $Revision: 24 $ 4# $Author: mhx $ 5# $Date: 2008/11/28 18:08:10 +0100 $ 6# 7################################################################################ 8# 9# Version 2.x, Copyright (C) 2007, Marcus Holland-Moritz <mhx@cpan.org>. 10# Version 1.x, Copyright (C) 1997, Graham Barr <gbarr@pobox.com>. 11# 12# This program is free software; you can redistribute it and/or 13# modify it under the same terms as Perl itself. 14# 15################################################################################ 16 17package IPC::SysV; 18 19use strict; 20use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION $XS_VERSION $AUTOLOAD); 21use Carp; 22use Config; 23 24require Exporter; 25@ISA = qw(Exporter); 26 27$VERSION = do { my @r = '$Snapshot: /IPC-SysV/2.01 $' =~ /(\d+\.\d+(?:_\d+)?)/; @r ? $r[0] : '9.99' }; 28$XS_VERSION = $VERSION; 29$VERSION = eval $VERSION; 30 31# To support new constants, just add them to @EXPORT_OK 32# and the C/XS code will be generated automagically. 33@EXPORT_OK = (qw( 34 35 GETALL GETNCNT GETPID GETVAL GETZCNT 36 37 IPC_ALLOC IPC_CREAT IPC_EXCL IPC_GETACL IPC_INFO IPC_LOCKED 38 IPC_M IPC_NOERROR IPC_NOWAIT IPC_PRIVATE IPC_R IPC_RMID 39 IPC_SET IPC_SETACL IPC_SETLABEL IPC_STAT IPC_W IPC_WANTED 40 41 MSG_EXCEPT MSG_FWAIT MSG_INFO MSG_LOCKED MSG_MWAIT MSG_NOERROR 42 MSG_QWAIT MSG_R MSG_RWAIT MSG_STAT MSG_W MSG_WAIT MSG_WWAIT 43 44 SEM_A SEM_ALLOC SEM_DEST SEM_ERR SEM_INFO SEM_ORDER SEM_R 45 SEM_STAT SEM_UNDO 46 47 SETALL SETVAL 48 49 SHMLBA 50 51 SHM_A SHM_CLEAR SHM_COPY SHM_DCACHE SHM_DEST SHM_ECACHE 52 SHM_FMAP SHM_HUGETLB SHM_ICACHE SHM_INFO SHM_INIT SHM_LOCK 53 SHM_LOCKED SHM_MAP SHM_NORESERVE SHM_NOSWAP SHM_R SHM_RDONLY 54 SHM_REMAP SHM_REMOVED SHM_RND SHM_SHARE_MMU SHM_SHATTR 55 SHM_SIZE SHM_STAT SHM_UNLOCK SHM_W 56 57 S_IRUSR S_IWUSR S_IXUSR S_IRWXU 58 S_IRGRP S_IWGRP S_IXGRP S_IRWXG 59 S_IROTH S_IWOTH S_IXOTH S_IRWXO 60 61 ENOSPC ENOSYS ENOMEM EACCES 62 63), qw( 64 65 ftok shmat shmdt memread memwrite 66 67)); 68 69sub AUTOLOAD 70{ 71 my $constname = $AUTOLOAD; 72 $constname =~ s/.*:://; 73 die "&IPC::SysV::_constant not defined" if $constname eq '_constant'; 74 my ($error, $val) = _constant($constname); 75 if ($error) { 76 my (undef, $file, $line) = caller; 77 die "$error at $file line $line.\n"; 78 } 79 { 80 no strict 'refs'; 81 *$AUTOLOAD = sub { $val }; 82 } 83 goto &$AUTOLOAD; 84} 85 86BOOT_XS: { 87 # If I inherit DynaLoader then I inherit AutoLoader and I DON'T WANT TO 88 require DynaLoader; 89 90 # DynaLoader calls dl_load_flags as a static method. 91 *dl_load_flags = DynaLoader->can('dl_load_flags'); 92 93 do { 94 __PACKAGE__->can('bootstrap') || \&DynaLoader::bootstrap 95 }->(__PACKAGE__, $XS_VERSION); 96} 97 981; 99 100__END__ 101 102=head1 NAME 103 104IPC::SysV - System V IPC constants and system calls 105 106=head1 SYNOPSIS 107 108 use IPC::SysV qw(IPC_STAT IPC_PRIVATE); 109 110=head1 DESCRIPTION 111 112C<IPC::SysV> defines and conditionally exports all the constants 113defined in your system include files which are needed by the SysV 114IPC calls. Common ones include 115 116 IPC_CREATE IPC_EXCL IPC_NOWAIT IPC_PRIVATE IPC_RMID IPC_SET IPC_STAT 117 GETVAL SETVAL GETPID GETNCNT GETZCNT GETALL SETALL 118 SEM_A SEM_R SEM_UNDO 119 SHM_RDONLY SHM_RND SHMLBA 120 121and auxiliary ones 122 123 S_IRUSR S_IWUSR S_IRWXU 124 S_IRGRP S_IWGRP S_IRWXG 125 S_IROTH S_IWOTH S_IRWXO 126 127but your system might have more. 128 129=over 4 130 131=item ftok( PATH ) 132 133=item ftok( PATH, ID ) 134 135Return a key based on PATH and ID, which can be used as a key for 136C<msgget>, C<semget> and C<shmget>. See L<ftok>. 137 138If ID is omitted, it defaults to C<1>. If a single character is 139given for ID, the numeric value of that character is used. 140 141=item shmat( ID, ADDR, FLAG ) 142 143Attach the shared memory segment identified by ID to the address 144space of the calling process. See L<shmat>. 145 146ADDR should be C<undef> unless you really know what you're doing. 147 148=item shmdt( ADDR ) 149 150Detach the shared memory segment located at the address specified 151by ADDR from the address space of the calling process. See L<shmdt>. 152 153=item memread( ADDR, VAR, POS, SIZE ) 154 155Reads SIZE bytes from a memory segment at ADDR starting at position POS. 156VAR must be a variable that will hold the data read. Returns true if 157successful, or false if there is an error. memread() taints the variable. 158 159=item memwrite( ADDR, STRING, POS, SIZE ) 160 161Writes SIZE bytes from STRING to a memory segment at ADDR starting at 162position POS. If STRING is too long, only SIZE bytes are used; if STRING 163is too short, nulls are written to fill out SIZE bytes. Returns true if 164successful, or false if there is an error. 165 166=back 167 168=head1 SEE ALSO 169 170L<IPC::Msg>, L<IPC::Semaphore>, L<IPC::SharedMem>, L<ftok>, L<shmat>, L<shmdt> 171 172=head1 AUTHORS 173 174Graham Barr <gbarr@pobox.com>, 175Jarkko Hietaniemi <jhi@iki.fi>, 176Marcus Holland-Moritz <mhx@cpan.org> 177 178=head1 COPYRIGHT 179 180Version 2.x, Copyright (C) 2007, Marcus Holland-Moritz. 181 182Version 1.x, Copyright (c) 1997, Graham Barr. 183 184This program is free software; you can redistribute it and/or 185modify it under the same terms as Perl itself. 186 187=cut 188 189