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

Contents of /trunk/httpserver_20080306/fd_utils.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Fri Mar 28 02:26:58 2008 UTC (13 years, 2 months ago) by plugwash
File size: 2232 byte(s)
initial import

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
38 implementation
39 uses sysutils;
40 Procedure FD_Clr(fd:longint;var fds:fdSet);{$ifdef fpc}inline;{$endif}
41 { Remove fd from the set of filedescriptors}
42 begin
43 if (fd < 0) then raise exception.create('FD_Clr fd out of range: '+inttostr(fd));
44 fds[fd shr 5]:=fds[fd shr 5] and (not (1 shl (fd and 31)));
45 end;
46
47 Procedure FD_Zero(var fds:fdSet);
48 { Clear the set of filedescriptors }
49 begin
50 FillChar(fds,sizeof(fdSet),0);
51 end;
52
53 Procedure FD_Set(fd:longint;var fds:fdSet);{$ifdef fpc}inline;{$endif}
54 { Add fd to the set of filedescriptors }
55 begin
56 if (fd < 0) then raise exception.create('FD_set fd out of range: '+inttostr(fd));
57 fds[fd shr 5]:=fds[fd shr 5] or (1 shl (fd and 31));
58 end;
59
60 Function FD_IsSet(fd:longint;var fds:fdSet):boolean;{$ifdef fpc}inline;{$endif}
61 { Test if fd is part of the set of filedescriptors }
62 begin
63 if (fd < 0) then begin
64 result := false;
65 exit;
66 end;
67 FD_IsSet:=((fds[fd shr 5] and (1 shl (fd and 31)))<>0);
68 end;
69 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.26