summaryrefslogtreecommitdiff
path: root/hurd/hurd_types.defs
blob: 9f176fef55a9f2f20ae263b8e541358926a3396f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
/* MiG type declarations for Hurd interfaces		-*- C -*-

   Copyright (C) 1993-1996, 1998, 2001, 2002, 2014-2019
   Free Software Foundation, Inc.

   This file is part of the GNU Hurd.

   The GNU Hurd is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   The GNU Hurd is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with the GNU Hurd.  If not, see <http://www.gnu.org/licenses/>.  */

#ifdef HURD_SERVER
/* The Hurd uses protected payloads to quickly look up the object
   receiving a message.  Looking up objects is optimized at the cost
   of having to translate payloads back to port names if the server
   function expect a port name rather than an object.

   Support for this is implemented in libports.  Almost all of Hurd's
   servers use libports.  For servers using libports, the optimized
   lookup is completely transparent.

   Servers not using libports are not using protected payloads
   automatically.  Define HURD_DEFAULT_PAYLOAD_TO_PORT to 1 (1 like
   the identity function) for programs not using libports to avoid
   injecting the default payload-to-port translation function which is
   in libports.  If you want to use protected payloads without
   libports, you can use HURD_DEFAULT_PAYLOAD_TO_PORT to inject a
   custom translation function.  */

#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
#if HURD_DEFAULT_PAYLOAD_TO_PORT
/* Any non-numeric value will fail this test.  If 1 (or any number) is
   given, do not inject the default translator function.  */
#undef HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#else
  import <hurd/ports.h>;
#define HURD_DEFAULT_PAYLOAD_TO_PORT ports_payload_get_name
#endif

/* Override the mach_port_t.  Use the default payload to port
   translation function to convert payloads back to port names for
   this type.  */
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
#define MACH_PAYLOAD_TO_PORT	HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif	/* HURD_SERVER */

#include <mach/std_types.defs>
#include <mach/mach_types.defs>
#include <device/device_types.defs>

/* The Hurd types.  You can inject translation functions for type X
   using the X_INTRAN, X_INTRAN_PAYLOAD, X_OUTTRAN, and X_DESTRUCTOR.

   If you define X_INTRAN and your server is using libports, you also
   have to define X_INTRAN_PAYLOAD.

   If you do not use libports, and do not want to use the protected
   payload mechanism, but you do want to use X_INTRAN, you must
   provide a X_INTRAN_PAYLOAD that either ignores the message by
   returning NULL, or indicates an error condition in some appropriate
   way.  If you do want to use the protected payload mechanism, make
   sure you also define an appropriate HURD_DEFAULT_PAYLOAD_TO_PORT
   translation function.  */

type file_t = mach_port_copy_send_t
#ifdef FILE_INTRAN
intran: FILE_INTRAN
intranpayload: FILE_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: file_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef FILE_OUTTRAN
outtran: FILE_OUTTRAN
#endif
#ifdef FILE_DESTRUCTOR
destructor: FILE_DESTRUCTOR
#endif
;

type fsys_t = mach_port_copy_send_t
#ifdef FSYS_INTRAN
intran: FSYS_INTRAN
intranpayload: FSYS_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: fsys_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef FSYS_OUTTRAN
outtran: FSYS_OUTTRAN
#endif
#ifdef FSYS_DESTRUCTOR
destructor: FSYS_DESTRUCTOR
#endif
;


type io_t = mach_port_copy_send_t
#ifdef IO_INTRAN
intran: IO_INTRAN
intranpayload: IO_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: io_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef IO_OUTTRAN
outtran: IO_OUTTRAN
#endif
#ifdef IO_DESTRUCTOR
destructor: IO_DESTRUCTOR
#endif
;

type process_t = mach_port_copy_send_t
#ifdef PROCESS_INTRAN
intran: PROCESS_INTRAN
intranpayload: PROCESS_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: process_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef PROCESS_OUTTRAN
outtran: PROCESS_OUTTRAN
#endif
#ifdef PROCESS_DESTRUCTOR
destructor: PROCESS_DESTRUCTOR
#endif
;

type auth_t = mach_port_copy_send_t
#ifdef AUTH_INTRAN
intran: AUTH_INTRAN
intranpayload: AUTH_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: auth_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef AUTH_OUTTRAN
outtran: AUTH_OUTTRAN
#endif
#ifdef AUTH_DESTRUCTOR
destructor: AUTH_DESTRUCTOR
#endif
;

type socket_t = mach_port_copy_send_t
#ifdef SOCKET_INTRAN
intran: SOCKET_INTRAN
intranpayload: SOCKET_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: socket_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef SOCKET_OUTTRAN
outtran: SOCKET_OUTTRAN
#endif
#ifdef SOCKET_DESTRUCTOR
destructor: SOCKET_DESTRUCTOR
#endif
;

/* Protocol family */
type pf_t = mach_port_copy_send_t
#ifdef PF_INTRAN
intran: PF_INTRAN
intranpayload: PF_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: pf_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef PF_OUTTRAN
outtran: PF_OUTTRAN
#endif
#ifdef PF_DESTRUCTOR
destructor: PF_DESTRUCTOR
#endif
;

type addr_port_t = mach_port_copy_send_t
#ifdef ADDRPORT_INTRAN
intran: ADDRPORT_INTRAN
intranpayload: ADDRPORT_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: addr_port_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef ADDRPORT_OUTTRAN
outtran: ADDRPORT_OUTTRAN
#endif
#ifdef ADDRPORT_DESTRUCTOR
destructor: ADDRPORT_DESTRUCTOR
#endif
;

type term_t = mach_port_copy_send_t
#ifdef TERM_INTRAN
intran: TERM_INTRAN
intranpayload: TERM_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: term_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef TERM_OUTTRAN
outtran: TERM_OUTTRAN
#endif
#ifdef TERM_DESTRUCTOR
destructor: TERM_DESTRUCTOR
#endif
;

type startup_t = mach_port_copy_send_t
#ifdef STARTUP_INTRAN
intran: STARTUP_INTRAN
intranpayload: STARTUP_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: startup_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef STARTUP_OUTTRAN
outtran: STARTUP_OUTTRAN
#endif
#ifdef STARTUP_DESTRUCTOR
destructor: STARTUP_DESTRUCTOR
#endif
;

type fs_notify_t = mach_port_copy_send_t
#ifdef FS_NOTIFY_INTRAN
intran: FS_NOTIFY_INTRAN
intranpayload: FS_NOTIFY_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: fs_notify_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef FS_NOTIFY_OUTTRAN
outtran: FS_NOTIFY_OUTTRAN
#endif
#ifdef FS_NOTIFY_DESTRUCTOR
destructor: FS_NOTIFY_DESTRUCTOR
#endif
;

type exec_startup_t = mach_port_copy_send_t
#ifdef EXEC_STARTUP_INTRAN
intran: EXEC_STARTUP_INTRAN
intranpayload: EXEC_STARTUP_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: exec_startup_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef EXEC_STARTUP_OUTTRAN
outtran: EXEC_STARTUP_OUTTRAN
#endif
#ifdef EXEC_STARTUP_DESTRUCTOR
destructor: EXEC_STARTUP_DESTRUCTOR
#endif
;

type interrupt_t = mach_port_copy_send_t
#ifdef INTERRUPT_INTRAN
intran: INTERRUPT_INTRAN
intranpayload: INTERRUPT_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: interrupt_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef INTERRUPT_OUTTRAN
outtran: INTERRUPT_OUTTRAN
#endif
#ifdef INTERRUPT_DESTRUCTOR
destructor: INTERRUPT_DESTRUCTOR
#endif
;

/* PCI arbiter */
type pci_t = mach_port_copy_send_t
#ifdef PCI_INTRAN
intran: PCI_INTRAN
intranpayload: PCI_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: pci_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef PCI_OUTTRAN
outtran: PCI_OUTTRAN
#endif
#ifdef PCI_DESTRUCTOR
destructor: PCI_DESTRUCTOR
#endif
;

/* Shutdown */
type shutdown_t = mach_port_copy_send_t
#ifdef SHUTDOWN_INTRAN
intran: SHUTDOWN_INTRAN
intranpayload: SHUTDOWN_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: shutdown_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef SHUTDOWN_OUTTRAN
outtran: SHUTDOWN_OUTTRAN
#endif
#ifdef SHUTDOWN_DESTRUCTOR
destructor: SHUTDOWN_DESTRUCTOR
#endif
;

/* ACPI */
type acpi_t = mach_port_copy_send_t
#ifdef ACPI_INTRAN
intran: ACPI_INTRAN
intranpayload: ACPI_INTRAN_PAYLOAD
#else
#ifdef HURD_DEFAULT_PAYLOAD_TO_PORT
intranpayload: acpi_t HURD_DEFAULT_PAYLOAD_TO_PORT
#endif
#endif
#ifdef ACPI_OUTTRAN
outtran: ACPI_OUTTRAN
#endif
#ifdef ACPI_DESTRUCTOR
destructor: ACPI_DESTRUCTOR
#endif
;

type proccoll_t = mach_port_copy_send_t;

type sreply_port_t = MACH_MSG_TYPE_MAKE_SEND_ONCE | polymorphic
	ctype: mach_port_t
#ifdef	MACH_PAYLOAD_TO_PORT
intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT
#endif	/* MACH_PAYLOAD_TO_PORT */
;

/* These macros are used in some .defs files so that every routine has a
   server reply port argument #ifdef REPLY_PORTS.  */
#ifdef REPLY_PORTS
#define RPTDECL	sreplyport reply: sreply_port_t
#define RPT	RPTDECL;
#define RPTLAST	; RPTDECL
#else
#define RPTLAST
#define RPT
#endif

/* This macros are used in some .defs files so that every out data_t
   (or equivalent) has a servercopy keyword #ifdef SERVERCOPY. */
#ifdef SERVERCOPY
#define SCP , servercopy
#else
#define SCP
#endif

#define RETURN_CODE_ARG in return_code: kern_return_t, retcode

#ifdef USERPREFIX
userprefix USERPREFIX;
#endif

#ifdef SERVERPREFIX
serverprefix SERVERPREFIX;
#endif

/* RPC interfaces which are interrupt compliant (see interrupt.defs)
   should put ``INTR_INTERFACE'' at the beginning of their .defs file.  */
#ifndef INTR_INTERFACE
#define INTR_INTERFACE		/* Nothing special.  */
#endif

type data_t = array[] of char;
type string_t = c_string[1024]; /* XXX */
type uid_t = uint32_t;
type gid_t = uint32_t;
type mode_t = uint32_t;
type retry_type = uint32_t;
type pid_t = int32_t;
type wait_status_t = int32_t;
type loff_t = int64_t;
type ino64_t = int64_t;
type file_changed_type_t = uint32_t;
type dir_changed_type_t = uint32_t;

type portarray_t = array[] of mach_port_send_t;
type intarray_t = array[] of int;
type off_array_t = array[] of loff_t;

type pidarray_t = array[] of pid_t;
type procinfo_t = array[] of int;

type idarray_t = array[] of uid_t;

type flock_t = struct {
   int l_type;
   int l_whence;
   loff_t l_start;
   loff_t l_len;
   pid_t l_pid;
};

type unsigned_int = uint32_t;
#if defined(__x86_64__)
type long = int64_t;
type unsigned_long = uint64_t;

/* Type names are in sync with glibc/posix/bits/types.h. */
type uword = unsigned_long;
type uquad = unsigned_long;
type squad = long;
#else
type long = int32_t;
type unsigned_long = uint32_t;

type uword = unsigned_int;
type uquad = uint64_t;
type squad = int64_t;
#endif /* defined(__x86_64__) */

type blksize_t = long;
type blkcnt64_t = squad;
type dev_t = uword;
type fsblkcnt64_t = uquad;
type fsfilcnt64_t = uquad;
type fsid_t = uquad;
type nlink_t = uword;

type time_t = long;

type timespec_t = struct {
  time_t tv_sec;
  long tv_nsec;
};
type timeval = timespec_t;

/* Dummy structure just to add padding to io_statbuf_t. */
type io_statbuf_spare_int = struct[8] of int;
/* Needs to be kept in sync with glibc/mach/hurd/bits/stat.h. */
type io_statbuf_t = struct {
   int st_fstype;
   fsid_t st_fsid;
   ino64_t st_ino;
   unsigned_int st_gen;
   dev_t st_rdev;
   mode_t st_mode;
   nlink_t st_nlink;
   uid_t st_uid;
   gid_t st_gid;
   loff_t st_size;
   timespec_t st_atim;
   timespec_t st_mtim;
   timespec_t st_ctim;
   blksize_t st_blksize;
   blkcnt64_t st_blocks;
   uid_t st_author;
   unsigned_int st_flags;
   io_statbuf_spare_int st_spare;
};

/* Needs to be kept in sync with glibc/mach/hurd/bits/statfs.h. */
type fsys_statfsbuf_t = struct {
   unsigned_int f_type;
   unsigned_long f_bsize;
   fsblkcnt64_t f_blocks;
   fsblkcnt64_t f_bfree;
   fsblkcnt64_t f_bavail;
   fsblkcnt64_t f_files;
   fsblkcnt64_t f_ffree;
   fsid_t f_fsid;
   unsigned_long f_namelen;
   fsfilcnt64_t f_favail;
   unsigned_long f_frsize;
   unsigned_long f_flag;
   unsigned_int f_spare1;
   unsigned_int f_spare2;
   unsigned_int f_spare3;
};

/* Needs to be kept in sync with glibc/resource/bits/types/struct_rusage.h. */
type rusage_t = struct {
   timeval ru_utime;
   timeval ru_stime;
   long ru_maxrss;
   long ru_ixrss;
   long ru_idrss;
   long ru_isrss;
   long ru_minflt;
   long ru_majflt;
   long ru_nswap;
   long ru_inblock;
   long ru_oublock;
   long ru_msgsnd;
   long ru_msgrcv;
   long ru_nsignals;
   long ru_nvcsw;
   long ru_nivcsw;
};

#define _SYS_UTSNAME_H		/* Inhibit warning from <bits/utsname.h>.  */
#include <bits/utsname.h>
type utsname_t = struct[5 * _UTSNAME_LENGTH] of char;

import <sys/types.h>;
import <sys/stat.h>;
import <sys/statfs.h>;
import <sys/resource.h>;
import <sys/utsname.h>;
import <hurd/hurd_types.h>;
import <fcntl.h>;