/[lcore]/trunk/fd_utils.pas
ViewVC logotype

Annotation of /trunk/fd_utils.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Fri Mar 28 02:26:58 2008 UTC (11 years, 7 months ago) by plugwash
File size: 2326 byte(s)
initial import

1 plugwash 1 // this file contains code copied from linux.pp in the free pascal rtl
2     // i had to copy them because i use a different definition of fdset to them
3     // the copyright block from the file in question is shown below
4     {
5     $Id: fd_utils.pas,v 1.2 2004/08/19 23:12:09 plugwash Exp $
6     This file is part of the Free Pascal run time library.
7     Copyright (c) 1999-2000 by Michael Van Canneyt,
8     BSD parts (c) 2000 by Marco van de Voort
9     members of the Free Pascal development team.
10    
11     See the file COPYING.FPC, included in this distribution,
12     for details about the copyright.
13    
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY;without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17    
18     **********************************************************************}
19     {$ifdef fpc}
20     {$mode delphi}
21     {$inlining on}
22     {$endif}
23     unit fd_utils;
24     interface
25    
26     type
27     FDSet= Array [0..255] of longint; {31}
28     PFDSet= ^FDSet;
29     const
30     absoloutemaxs=(sizeof(fdset)*8)-1;
31    
32     Procedure FD_Clr(fd:longint;var fds:fdSet);
33     Procedure FD_Zero(var fds:fdSet);
34     Procedure FD_Set(fd:longint;var fds:fdSet);
35     Function FD_IsSet(fd:longint;var fds:fdSet):boolean;
36    
37     {$ifdef fpc}
38     {$ifndef ver1_0}
39     {$define useinline}
40     {$endif}
41     {$endif}
42    
43     implementation
44     uses sysutils;
45     Procedure FD_Clr(fd:longint;var fds:fdSet);{$ifdef useinline}inline;{$endif}
46     { Remove fd from the set of filedescriptors}
47     begin
48     if (fd < 0) then raise exception.create('FD_Clr fd out of range: '+inttostr(fd));
49     fds[fd shr 5]:=fds[fd shr 5] and (not (1 shl (fd and 31)));
50     end;
51    
52     Procedure FD_Zero(var fds:fdSet);
53     { Clear the set of filedescriptors }
54     begin
55     FillChar(fds,sizeof(fdSet),0);
56     end;
57    
58     Procedure FD_Set(fd:longint;var fds:fdSet);{$ifdef useinline}inline;{$endif}
59     { Add fd to the set of filedescriptors }
60     begin
61     if (fd < 0) then raise exception.create('FD_set fd out of range: '+inttostr(fd));
62     fds[fd shr 5]:=fds[fd shr 5] or (1 shl (fd and 31));
63     end;
64    
65     Function FD_IsSet(fd:longint;var fds:fdSet):boolean;{$ifdef useinline}inline;{$endif}
66     { Test if fd is part of the set of filedescriptors }
67     begin
68     if (fd < 0) then begin
69     result := false;
70     exit;
71     end;
72     FD_IsSet:=((fds[fd shr 5] and (1 shl (fd and 31)))<>0);
73     end;
74     end.

Properties

Name Value
svn:executable

No admin address has been configured">No admin address has been configured
ViewVC Help
Powered by ViewVC 1.1.22