├── debian ├── docs ├── compat ├── source │ └── format ├── changelog ├── rules ├── control └── copyright ├── tests └── test_libcgc.py ├── _terminate.md ├── Makefile ├── receive.md ├── transmit.md ├── random.md ├── deallocate.md ├── allocate.md ├── libcgc.h ├── fdwait.md ├── libcgc.s ├── maths.s └── cgcabi.md /debian/docs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | libcgc (10206-cfe-rc6) UNRELEASED; urgency=low 2 | 3 | * build 4 | 5 | -- Brian Caswell Tue, 12 Jul 2016 14:41:27 +0000 6 | 7 | libcgc (0.1) unstable; urgency=low 8 | 9 | * Initial Release. 10 | 11 | -- Brian Caswell Wed, 05 Mar 2014 17:43:19 +0000 12 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) 4 | CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) 5 | CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) 6 | LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) 7 | 8 | override_dh_strip: 9 | echo "not stripping" 10 | 11 | %: 12 | dh $@ 13 | 14 | -------------------------------------------------------------------------------- /tests/test_libcgc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import os 4 | import sys 5 | import unittest 6 | import time 7 | import subprocess 8 | 9 | class test_libcgc(unittest.TestCase): 10 | def test_template(self): 11 | self.assertTrue("unit tests should be written for this package") 12 | 13 | if __name__ == '__main__': 14 | unittest.main() 15 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: libcgc 2 | Section: devel 3 | Priority: standard 4 | Maintainer: Brian Caswell 5 | Build-Depends: debhelper (>= 8.0.0), binutils-cgc-i386 6 | Standards-Version: 3.9.3 7 | Homepage: http://www.darpa.mil/cybergrandchallenge/ 8 | 9 | Package: libcgc 10 | Architecture: any 11 | Depends: ${shlibs:Depends}, ${misc:Depends} 12 | Description: CGC OS syscall library 13 | libcgc provides the library that communicates with CGCOS execution enviornment. 14 | -------------------------------------------------------------------------------- /_terminate.md: -------------------------------------------------------------------------------- 1 | % CGC Application Binary Interface 2 | 3 | # NAME 4 | *_terminate* - terminate the execution of a program 5 | 6 | # LIBRARY 7 | library "libcgc" 8 | 9 | # SYNOPSIS 10 | \#include \ 11 | 12 | _void_ **_terminate**(_int status_) 13 | 14 | # DESCRIPTION 15 | The *_terminate* system call terminates a process. All file descriptors 16 | open in the process are flushed and closed. The scoring system is notified 17 | of the value of *status*. 18 | 19 | The *_terminate* function is invoked through system call number 1. 20 | 21 | # RETURN VALUE 22 | The *_terminate* system call never returns. 23 | 24 | # SEE ALSO 25 | allocate(2), 26 | cgcabi(2), 27 | deallocate(2), 28 | fdwait(2), 29 | random(2), 30 | receive(2), 31 | transmit(2) 32 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | LIBDIR=$(DESTDIR)/usr/lib 2 | INCDIR=$(DESTDIR)/usr/include 3 | MANDIR=$(DESTDIR)/usr/share/man/man2 4 | 5 | PATH=/usr/i386-linux-cgc/bin:/bin:/usr/bin 6 | 7 | .SUFFIXES: .md .2.gz 8 | 9 | ASFLAGS= 10 | 11 | %.2.gz: %.md 12 | pandoc -s -t man $< | gzip -9 > $@ 13 | 14 | all: libcgc.a \ 15 | allocate.2.gz deallocate.2.gz fdwait.2.gz random.2.gz receive.2.gz \ 16 | _terminate.2.gz transmit.2.gz cgcabi.2.gz 17 | 18 | libcgc.a: libcgc.o maths.o 19 | $(AR) cruv $@ libcgc.o maths.o 20 | 21 | libcgc.o: libcgc.s 22 | $(AS) -o $@ $< $(ASFLAGS) 23 | 24 | maths.o: maths.s 25 | $(AS) -o $@ $< $(ASFLAGS) 26 | 27 | install: libcgc.a 28 | install -d $(LIBDIR) 29 | install -d $(INCDIR) 30 | install libcgc.a $(LIBDIR) 31 | install libcgc.h $(INCDIR) 32 | install -d $(MANDIR) 33 | install -m 444 allocate.2.gz $(MANDIR) 34 | install -m 444 cgcabi.2.gz $(MANDIR) 35 | install -m 444 deallocate.2.gz $(MANDIR) 36 | install -m 444 fdwait.2.gz $(MANDIR) 37 | install -m 444 random.2.gz $(MANDIR) 38 | install -m 444 receive.2.gz $(MANDIR) 39 | install -m 444 _terminate.2.gz $(MANDIR) 40 | install -m 444 transmit.2.gz $(MANDIR) 41 | 42 | clean: 43 | rm -f libcgc.[oa] *.2.gz maths.o 44 | -------------------------------------------------------------------------------- /receive.md: -------------------------------------------------------------------------------- 1 | % CGC Application Binary Interface 2 | 3 | # NAME 4 | *receive* - receive bytes from a file descriptor 5 | 6 | # LIBRARY 7 | library "libcgc" 8 | 9 | # SYNOPSIS 10 | \#include \ 11 | 12 | _int_ 13 | **receive**(_int fd_, _void *buf_, _size_t count_, _size_t *rx_bytes_) 14 | 15 | # DESCRIPTION 16 | The *receive* system call reads up to *count* bytes from file descriptor 17 | *fd* to the buffer pointed to by *buf*. If *count* is zero, *receive* 18 | returns 0 and optionally sets *\*rx_bytes* to zero. 19 | 20 | The *receive* function is invoked through system call number 3. 21 | 22 | # RETURN VALUE 23 | On success, zero is returned and, if *rx_bytes* is not *NULL*, the number 24 | of bytes received is returned in *\*rx_bytes* (zero indicates nothing 25 | was received or end-of-file). On error, an error code is returned and 26 | *\*rx_bytes* is left unmodified. 27 | 28 | # ERRORS 29 | 30 | ------ -------------------------------------------------------------- 31 | EBADF *fd* is not a valid file descriptor or is not open. 32 | EFAULT *buf* or *rx_bytes* points to an invalid address. 33 | ------ -------------------------------------------------------------- 34 | 35 | # SEE ALSO 36 | allocate(2), 37 | cgcabi(2), 38 | deallocate(2), 39 | fdwait(2), 40 | random(2), 41 | _terminate(2), 42 | transmit(2) 43 | -------------------------------------------------------------------------------- /transmit.md: -------------------------------------------------------------------------------- 1 | % CGC Application Binary Interface 2 | 3 | # NAME 4 | *transmit* - send bytes through a file descriptor 5 | 6 | # LIBRARY 7 | library "libcgc" 8 | 9 | # SYNOPSIS 10 | \#include \ 11 | 12 | _int_ **transmit**(_int fd_, _const void *buf_, _size_t count_, _size_t *tx_bytes_) 13 | 14 | # DESCRIPTION 15 | The *transmit* system call writes up to *count* bytes from the buffer 16 | pointed to by *buf* to the file descriptor *fd*. If *count* is zero, 17 | *transmit* returns 0 and optionally sets *\*tx_bytes* to zero. 18 | 19 | The *transmit* function is invoked through system call number 2. 20 | 21 | # RETURN VALUE 22 | On success, zero is returned and, if *tx_bytes* is not *NULL*, the number 23 | of bytes transmitted in returned in *\*tx_bytes* (zero indicates nothing 24 | was transmitted). On error, an error code is returned and *\*tx_bytes* 25 | is left unmodified. 26 | 27 | # ERRORS 28 | 29 | ------ -------------------------------------------------------------- 30 | EBADF *fd* is not a valid file descriptor or is not open. 31 | EFAULT *buf* or *tx_bytes* points to an invalid address. 32 | ------ -------------------------------------------------------------- 33 | 34 | # SEE ALSO 35 | allocate(2), 36 | cgcabi(2), 37 | deallocate(2), 38 | fdwait(2), 39 | random(2), 40 | receive(2), 41 | _terminate(2) 42 | -------------------------------------------------------------------------------- /random.md: -------------------------------------------------------------------------------- 1 | % CGC Application Binary Interface 2 | 3 | # NAME 4 | *random* - fill a buffer with random data 5 | 6 | # LIBRARY 7 | library "libcgc" 8 | 9 | # SYNOPSIS 10 | \#include \ 11 | 12 | _int_ **random**(_void *buf_, _size_t count_, _size_t *rnd_bytes_) 13 | 14 | # DESCRIPTION 15 | The *random* system call populates the buffer referenced by *buf* 16 | with up to count bytes of random data. If *count* is zero, *random* 17 | returns 0 and optionally sets *\*rnd_bytes* to zero. 18 | If *count* is greater than *SSIZE_MAX*, the result is unspecified. 19 | 20 | The *random* function is invoked through system call number 7. 21 | 22 | # RETURN VALUE 23 | On success, zero is returned and if *rnd_bytes* is not *NULL*, the 24 | number of bytes copied into *buf* is returned in *\*rnd_bytes*. 25 | On error, an error code is returned, the contents of *\*buf* 26 | are undefined, and the value of *\*rnd_bytes* is left unmodified. 27 | 28 | # ERRORS 29 | ------ -------------------------------------------------------------- 30 | EINVAL *count* is invalid. 31 | EFAULT *buf* or *rnd_bytes* points to an invalid address. 32 | ------ -------------------------------------------------------------- 33 | 34 | # SEE ALSO 35 | allocate(2), 36 | cgcabi(2), 37 | deallocate(2), 38 | fdwait(2), 39 | receive(2), 40 | _terminate(2), 41 | transmit(2) 42 | -------------------------------------------------------------------------------- /deallocate.md: -------------------------------------------------------------------------------- 1 | % CGC Application Binary Interface 2 | 3 | # NAME 4 | *deallocate* - remove allocations 5 | 6 | # LIBRARY 7 | library "libcgc" 8 | 9 | # SYNOPSIS 10 | \#include \ 11 | 12 | _int_ **deallocate**(_void *addr_, _size_t length_) 13 | 14 | # DESCRIPTION 15 | The *deallocate* system call deletes the allocations for the specified 16 | address range, and causes further references to the addresses within the 17 | range to generate invalid memory accesses. The region is also automatically 18 | deallocated when the process is terminated. 19 | 20 | The address *addr* must be a multiple of the page size. The *length* 21 | parameter specifies the size of the region to be deallocated in bytes. 22 | All pages containing a part of the indicated range are deallocated, and 23 | subsequent references will terminate the process. It is not an error if 24 | the indicated range does not contain any allocated pages. 25 | 26 | The *deallocate* function is invoked through system call number 6. 27 | 28 | # RETURN VALUE 29 | On success, *deallocate* returns 0; otherwise an error code is returned. 30 | 31 | # ERRORS 32 | 33 | ------ -------------------------------------------------------------- 34 | EINVAL *addr* is not page aligned. 35 | EINVAL *length* is zero. 36 | EINVAL any part of the region being deallocated is outside the valid address range of the process. 37 | ------ -------------------------------------------------------------- 38 | 39 | # SEE ALSO 40 | allocate(2), 41 | cgcabi(2), 42 | fdwait(2), 43 | random(2). 44 | receive(2), 45 | _terminate(2), 46 | transmit(2) 47 | -------------------------------------------------------------------------------- /allocate.md: -------------------------------------------------------------------------------- 1 | % CGC Application Binary Interface 2 | 3 | # NAME 4 | *allocate* - allocate virtual memory 5 | 6 | # LIBRARY 7 | library "libcgc" 8 | 9 | # SYNOPSIS 10 | \#include \ 11 | 12 | _int_ **allocate**(_size_t length_, _int is_X_, _void **addr_) 13 | 14 | # DESCRIPTION 15 | The *allocate* system call creates a new allocation in the virtual address 16 | space of the calling process. The length argument specifies the length of 17 | the allocation in bytes which will be rounded up to the hardware page size 18 | (4KB for IA32). 19 | 20 | The kernel chooses the address at which to create the allocation; 21 | the address of the new allocation is returned in *\*addr* 22 | as the result of the call, and is always page aligned. 23 | 24 | All newly allocated memory is zero-filled, readable, and writeable. 25 | In addition, the *is_X* argument is a boolean that allows newly allocated 26 | memory to be marked as executable (non-zero) or non-executable (zero). 27 | 28 | The allocate function is invoked through system call number 5. 29 | 30 | # RETURN VALUE 31 | On success, *allocate* returns zero and a pointer to the allocated area 32 | is returned in *\*addr*. Otherwise, an error code is returned and 33 | *\*addr* is undefined. 34 | 35 | # ERRORS 36 | 37 | ------ -------------------------------------------------------------- 38 | EINVAL *length* is zero. 39 | EINVAL *length* is too large. 40 | EFAULT *addr* points to an invalid address. 41 | ENOMEM No memory is available or the process' maximum number of allocations would have been exceeded. 42 | ------ -------------------------------------------------------------- 43 | 44 | # SEE ALSO 45 | cgcabi(2), 46 | deallocate(2), 47 | fdwait(2), 48 | random(2). 49 | receive(2), 50 | _terminate(2), 51 | transmit(2) 52 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: cgc-service-launcher 3 | Source: http://www.darpa.mil/cybergrandchallenge 4 | 5 | Files: * 6 | Copyright: 2014 Jason Wright 7 | License: MIT 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | . 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | . 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | Files: debian/* 27 | Copyright: 2014 Brian Caswell 28 | License: MIT 29 | Permission is hereby granted, free of charge, to any person obtaining a 30 | copy of this software and associated documentation files (the "Software"), 31 | to deal in the Software without restriction, including without limitation 32 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 33 | and/or sell copies of the Software, and to permit persons to whom the 34 | Software is furnished to do so, subject to the following conditions: 35 | . 36 | The above copyright notice and this permission notice shall be included 37 | in all copies or substantial portions of the Software. 38 | . 39 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 40 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 41 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 43 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 44 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 45 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 46 | -------------------------------------------------------------------------------- /libcgc.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBCGC_H 2 | #define _LIBCGC_H 3 | 4 | #define STDIN 0 5 | #define STDOUT 1 6 | #define STDERR 2 7 | 8 | #define NULL ((void *)0) 9 | 10 | typedef long unsigned int size_t; 11 | typedef long signed int ssize_t; 12 | 13 | #define SSIZE_MAX 2147483647 14 | #define SIZE_MAX 4294967295 15 | #define FD_SETSIZE 1024 16 | 17 | typedef long int _fd_mask; 18 | 19 | #define _NFDBITS (8 * sizeof(_fd_mask)) 20 | 21 | typedef struct { 22 | _fd_mask _fd_bits[FD_SETSIZE / _NFDBITS]; 23 | } fd_set; 24 | 25 | #define FD_ZERO(set) \ 26 | do { \ 27 | int __i; \ 28 | for (__i = 0; __i < (FD_SETSIZE / _NFDBITS); __i++) \ 29 | (set)->_fd_bits[__i] = 0; \ 30 | } while (0) 31 | #define FD_SET(b, set) \ 32 | ((set)->_fd_bits[b / _NFDBITS] |= (1 << (b & (_NFDBITS - 1)))) 33 | #define FD_CLR(b, set) \ 34 | ((set)->_fd_bits[b / _NFDBITS] &= ~(1 << (b & (_NFDBITS - 1)))) 35 | #define FD_ISSET(b, set) \ 36 | ((set)->_fd_bits[b / _NFDBITS] & (1 << (b & (_NFDBITS - 1)))) 37 | 38 | struct timeval { 39 | int tv_sec; 40 | int tv_usec; 41 | }; 42 | 43 | #define EBADF 1 44 | #define EFAULT 2 45 | #define EINVAL 3 46 | #define ENOMEM 4 47 | #define ENOSYS 5 48 | #define EPIPE 6 49 | 50 | void _terminate(unsigned int status) __attribute__((__noreturn__)); 51 | int transmit(int fd, const void *buf, size_t count, size_t *tx_bytes); 52 | int receive(int fd, void *buf, size_t count, size_t *rx_bytes); 53 | int fdwait(int nfds, fd_set *readfds, fd_set *writefds, 54 | const struct timeval *timeout, int *readyfds); 55 | int allocate(size_t length, int is_X, void **addr); 56 | int deallocate(void *addr, size_t length); 57 | int random(void *buf, size_t count, size_t *rnd_bytes); 58 | 59 | typedef struct { long _b[8]; } jmp_buf[1]; 60 | int setjmp(jmp_buf) __attribute__((__returns_twice__)); 61 | void longjmp(jmp_buf, int) __attribute__((__noreturn__)); 62 | 63 | float sinf(float); double sin(double); long double sinl(long double); 64 | float cosf(float); double cos(double); long double cosl(long double); 65 | float tanf(float); double tan(double); long double tanl(long double); 66 | float logf(float); double log(double); long double logl(long double); 67 | float rintf(float); double rint(double); long double rintl(long double); 68 | float sqrtf(float); double sqrt(double); long double sqrtl(long double); 69 | float fabsf(float); double fabs(double); long double fabsl(long double); 70 | float log2f(float); double log2(double); long double log2l(long double); 71 | float exp2f(float); double exp2(double); long double exp2l(long double); 72 | float expf(float); double exp(double); long double expl(long double); 73 | float log10f(float); double log10(double); long double log10l(long double); 74 | float powf(float, float); 75 | double pow(double, double); 76 | long double powl(long double, long double); 77 | float atan2f(float, float); 78 | double atan2(double, double); 79 | long double atan2l(long double, long double); 80 | float remainderf(float, float); 81 | double remainder(double, double); 82 | long double remainderl(long double, long double); 83 | float scalbnf(float, int); 84 | double scalbn(double, int); 85 | long double scalbnl(long double, int); 86 | float scalblnf(float, long int); 87 | double scalbln(double, long int); 88 | long double scalblnl(long double, long int); 89 | float significandf(float); 90 | double significand(double); 91 | long double significandl(long double); 92 | 93 | #endif /* _LIBCGC_H */ 94 | -------------------------------------------------------------------------------- /fdwait.md: -------------------------------------------------------------------------------- 1 | % CGC Application Binary Interface 2 | 3 | # NAME 4 | *fdwait* - wait for file descriptors to become ready 5 | 6 | # LIBRARY 7 | library "libcgc" 8 | 9 | # SYNOPSIS 10 | \#include \ 11 | 12 | _int_ **fdwait**(_int nfds_, _fd_set *readfds_, _fd_set *writefds_, _const struct timeval *timeout_, _int *readyfds_) 13 | 14 | # DESCRIPTION 15 | The *fdwait* system call allows a program to monitor multiple file descriptors, 16 | waiting until one or more of the descriptors become "ready" for some class of 17 | I/O operation (e.g., input possible). A file descriptor is considered ready if 18 | it is possible to perform the corresponding I/O operation (e.g., receive(2)) 19 | without blocking. 20 | 21 | Two independent sets of file descriptors are watched. Those listed in 22 | *readfds* will be watched to see if characters become available for reading 23 | (more precisely, to see if a read will not block; in particular, a file 24 | descriptor is also ready on end-of-file), and those in *writefds* will be 25 | watched to see if a write will not block. On exit, the sets are modified 26 | in place to indicate which file descriptors actually changed status. 27 | Each of the two file descriptor sets may be specified as 28 | *NULL* if no file descriptors are to be watched for the corresponding class 29 | of events. 30 | 31 | Four macros are provided to manipulate the sets. *FD_ZERO* clears a set. 32 | *FD_SET* and *FD_CLR* respectively add and remove a given file descriptor 33 | from a set. *FD_ISSET* tests to see if a file descriptor is part of the set; 34 | this is useful after *fdwait* returns. 35 | 36 | The *nfds* parameter is the highest-numbered file descriptor in any of the 37 | two sets, plus 1. 38 | 39 | The timeout argument specifies the minimum interval that *fdwait* should 40 | block waiting for a file descriptor to become ready. This interval will be 41 | rounded up to the system clock granularity, and kernel scheduling delays 42 | mean that the blocking interval may overrun by a small amount. 43 | If both fields of the timeval structure are zero, then *fdwait* returns 44 | immediately (useful for polling). If timeout is *NULL* (no timeout), 45 | *fdwait* can block indefinitely. 46 | 47 | The fdwait function is invoked through system call number 4. 48 | 49 | # RETURN VALUE 50 | On success, *fdwait* returns zero and, if *readyfds* is not *NULL*, 51 | *\*readyfds* is set to the number of file descriptors contained in the two 52 | returned descriptor sets (that is, the total number of bits that are set in 53 | *readfds* and *writefds*) which may be zero if the timeout expires before 54 | anything interesting happens. 55 | 56 | On error, an error code is returned and *\*readyfds* is undefined; 57 | the sets become undefined, so do not rely on their contents after an error. 58 | 59 | # ERRORS 60 | 61 | ------ -------------------------------------------------------------- 62 | EBADF an invalid file descriptor was given in one of the sets (perhaps a file descriptor that was already closed, or one on which an error has occurred). 63 | EINVAL *nfds* is negative or the value contained within *\*timeout* is invalid. 64 | EFAULT One of the arguments *readfds*, *writefds*, *timeout*, *readyfds* points to an invalid address. 65 | ENOMEM unable to allocate memory for internal tables. 66 | ------ -------------------------------------------------------------- 67 | 68 | # SEE ALSO 69 | allocate(2), 70 | cgcabi(2), 71 | deallocate(2), 72 | random(2). 73 | receive(2), 74 | _terminate(2), 75 | transmit(2) 76 | -------------------------------------------------------------------------------- /libcgc.s: -------------------------------------------------------------------------------- 1 | 2 | .macro sys_call n 3 | movl $\n, %eax 4 | .endm 5 | 6 | .macro do_syscall 7 | int $0x80 8 | .endm 9 | 10 | .macro syscall_arg_1 11 | pushl %ebx 12 | movl 8(%esp), %ebx 13 | do_syscall 14 | popl %ebx 15 | ret 16 | .endm 17 | 18 | .macro syscall_arg_2 19 | pushl %ebx 20 | pushl %ecx 21 | movl 12(%esp), %ebx 22 | movl 16(%esp), %ecx 23 | do_syscall 24 | popl %ecx 25 | popl %ebx 26 | ret 27 | .endm 28 | 29 | .macro syscall_arg_3 30 | pushl %ebx 31 | pushl %ecx 32 | pushl %edx 33 | movl 16(%esp), %ebx 34 | movl 20(%esp), %ecx 35 | movl 24(%esp), %edx 36 | do_syscall 37 | popl %edx 38 | popl %ecx 39 | popl %ebx 40 | ret 41 | .endm 42 | 43 | .macro syscall_arg_4 44 | pushl %ebx 45 | pushl %ecx 46 | pushl %edx 47 | pushl %esi 48 | movl 20(%esp), %ebx 49 | movl 24(%esp), %ecx 50 | movl 28(%esp), %edx 51 | movl 32(%esp), %esi 52 | do_syscall 53 | popl %esi 54 | popl %edx 55 | popl %ecx 56 | popl %ebx 57 | ret 58 | .endm 59 | 60 | .macro syscall_arg_5 61 | pushl %ebx 62 | pushl %ecx 63 | pushl %edx 64 | pushl %esi 65 | pushl %edi 66 | movl 24(%esp), %ebx 67 | movl 28(%esp), %ecx 68 | movl 32(%esp), %edx 69 | movl 36(%esp), %esi 70 | movl 40(%esp), %edi 71 | do_syscall 72 | popl %edi 73 | popl %esi 74 | popl %edx 75 | popl %ecx 76 | popl %ebx 77 | ret 78 | .endm 79 | 80 | .macro syscall_arg_6 81 | pushl %ebx 82 | pushl %ecx 83 | pushl %edx 84 | pushl %esi 85 | pushl %edi 86 | pushl %ebp 87 | movl 28(%esp), %ebx 88 | movl 32(%esp), %ecx 89 | movl 36(%esp), %edx 90 | movl 40(%esp), %esi 91 | movl 44(%esp), %edi 92 | movl 48(%esp), %ebp 93 | do_syscall 94 | popl %ebp 95 | popl %edi 96 | popl %esi 97 | popl %edx 98 | popl %ecx 99 | popl %ebx 100 | ret 101 | .endm 102 | 103 | .macro ENTER base 104 | .global \base 105 | .type \base, @function 106 | \base: 107 | .endm 108 | 109 | .macro SENTER base 110 | .type \base, @function 111 | \base: 112 | .endm 113 | 114 | .macro END base 115 | .size \base, . - \base 116 | .endm 117 | 118 | ENTER _start 119 | call _crcx 120 | call main 121 | pushl %eax 122 | call _terminate 123 | END _start 124 | 125 | ENTER _terminate 126 | sys_call 1 127 | syscall_arg_1 128 | END _terminate 129 | 130 | ENTER transmit 131 | sys_call 2 132 | syscall_arg_4 133 | END transmit 134 | 135 | ENTER receive 136 | sys_call 3 137 | syscall_arg_4 138 | END receive 139 | 140 | ENTER fdwait 141 | sys_call 4 142 | syscall_arg_5 143 | END fdwait 144 | 145 | ENTER allocate 146 | sys_call 5 147 | syscall_arg_3 148 | END allocate 149 | 150 | ENTER deallocate 151 | sys_call 6 152 | syscall_arg_2 153 | END deallocate 154 | 155 | ENTER random 156 | sys_call 7 157 | syscall_arg_3 158 | END random 159 | 160 | ENTER setjmp 161 | movl 4(%esp), %ecx 162 | movl 0(%esp), %edx 163 | movl %edx, 0(%ecx) 164 | movl %ebx, 4(%ecx) 165 | movl %esp, 8(%ecx) 166 | movl %ebp, 12(%ecx) 167 | movl %esi, 16(%ecx) 168 | movl %edi, 20(%ecx) 169 | xorl %eax, %eax 170 | ret 171 | END setjmp 172 | 173 | ENTER longjmp 174 | movl 4(%esp), %edx 175 | movl 8(%esp), %eax 176 | movl 0(%edx), %ecx 177 | movl 4(%edx), %ebx 178 | movl 8(%edx), %esp 179 | movl 12(%edx), %ebp 180 | movl 16(%edx), %esi 181 | movl 20(%edx), %edi 182 | testl %eax, %eax 183 | jnz 1f 184 | incl %eax 185 | 1: movl %ecx, 0(%esp) 186 | ret 187 | END longjmp 188 | 189 | .macro push_crc_arg n 190 | .weak \n 191 | pushl $\n 192 | .endm 193 | 194 | SENTER _crcx 195 | pushl $0 196 | push_crc_arg _binary_build_release_dpkg_o_txt_start 197 | push_crc_arg _binary_build_release_dpkg_o_txt_end 198 | call _crcx_docrc 199 | addl $12, %esp 200 | 201 | pushl $0 202 | pushl $0 203 | pushl $0 204 | pushl $0 205 | pushl $0 206 | pushl $0 207 | addl $6*4, %esp 208 | pushfl 209 | popl %eax 210 | andl $~0xc4, %eax 211 | pushl %eax 212 | popfl 213 | pushl $0 214 | popl %eax 215 | 216 | ret 217 | END _crcx 218 | 219 | SENTER _crcx_docrc 220 | pushl %esi 221 | pushl %ecx 222 | movl 12(%esp), %ecx 223 | movl 16(%esp), %esi 224 | movl 20(%esp), %eax 225 | subl %esi, %ecx 226 | jz 2f 227 | 228 | 1: xorb (%esi), %al 229 | inc %esi 230 | loop 1b 231 | 232 | 2: popl %ecx 233 | popl %esi 234 | ret 235 | END _crcx_docrc 236 | 237 | -------------------------------------------------------------------------------- /maths.s: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Copyright (c) 2014 Jason L. Wright (jason@thought.net) 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 24 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | # POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | 28 | # basic assembly math routines for DARPA Cyber Grand Challenge 29 | 30 | .macro ENTER base 31 | .global \base, \base\()f, \base\()l 32 | .type \base, @function 33 | .type \base\()f, @function 34 | .type \base\()l, @function 35 | .endm 36 | 37 | .macro END base 38 | .size \base, . - \base 39 | .size \base\()f, . - \base\()f 40 | .size \base\()l, . - \base\()l 41 | .endm 42 | 43 | ENTER sin 44 | sinl: fldt 4(%esp) 45 | jmp 1f 46 | sinf: flds 4(%esp) 47 | jmp 1f 48 | sin: 49 | fldl 4(%esp) 50 | 1: fsin 51 | fnstsw %ax 52 | sahf 53 | jp 2f 54 | ret 55 | 2: call twopi_rem 56 | fsin 57 | ret 58 | END sin 59 | 60 | ENTER cos 61 | cosl: fldt 4(%esp) 62 | jmp 1f 63 | cosf: flds 4(%esp) 64 | jmp 1f 65 | cos: fldl 4(%esp) 66 | 1: fcos 67 | fnstsw %ax 68 | sahf 69 | jp 2f 70 | ret 71 | 2: call twopi_rem 72 | fcos 73 | ret 74 | END cos 75 | 76 | ENTER tan 77 | tanl: fldt 4(%esp) 78 | jmp 1f 79 | tanf: flds 4(%esp) 80 | jmp 1f 81 | tan: fldl 4(%esp) 82 | 1: fptan 83 | fnstsw %ax 84 | sahf 85 | jp 2f 86 | fstp %st(0) 87 | ret 88 | 2: call twopi_rem 89 | fptan 90 | fstp %st(0) 91 | ret 92 | END tan 93 | 94 | .type twopi_rem, @function 95 | twopi_rem: 96 | fldpi 97 | fadd %st(0) 98 | fxch %st(1) 99 | 1: fprem 100 | fnstsw %ax 101 | sahf 102 | jp 1b 103 | fstp %st(1) 104 | ret 105 | .size twopi_rem, . - twopi_rem 106 | 107 | ENTER remainder 108 | remainderl: 109 | fldt 16(%esp) 110 | fldt 4(%esp) 111 | jmp 1f 112 | remainderf: 113 | flds 8(%esp) 114 | flds 4(%esp) 115 | jmp 1f 116 | remainder: 117 | fldl 12(%esp) 118 | fldl 4(%esp) 119 | 1: fprem1 120 | fstsw %ax 121 | sahf 122 | jp 1b 123 | fstp %st(1) 124 | ret 125 | END remainder 126 | 127 | ENTER log 128 | logl: fldt 4(%esp) 129 | jmp 1f 130 | logf: flds 4(%esp) 131 | jmp 1f 132 | log: fldl 4(%esp) 133 | 1: fldln2 134 | fxch %st(1) 135 | fyl2x 136 | ret 137 | END log 138 | 139 | ENTER log10 140 | log10l: fldt 4(%esp) 141 | jmp 1f 142 | log10f: flds 4(%esp) 143 | jmp 1f 144 | log10: fldl 4(%esp) 145 | 1: fldlg2 146 | fxch %st(1) 147 | fyl2x 148 | ret 149 | END log10 150 | 151 | ENTER significand 152 | significandl: 153 | fldt 4(%esp) 154 | jmp 1f 155 | significandf: 156 | flds 4(%esp) 157 | jmp 1f 158 | significand: 159 | fldl 4(%esp) 160 | 1: fxtract 161 | fstp %st(1) 162 | ret 163 | END significand 164 | 165 | ENTER scalbn 166 | ENTER scalbln 167 | scalbnl: 168 | scalblnl: 169 | fildl 16(%esp) 170 | fldt 4(%esp) 171 | jmp 1f 172 | scalbnf: 173 | scalblnf: 174 | fildl 8(%esp) 175 | flds 4(%esp) 176 | jmp 1f 177 | scalbn: 178 | scalbln: 179 | fildl 12(%esp) 180 | fldl 4(%esp) 181 | 1: fscale 182 | fstp %st(1) 183 | ret 184 | END scalbn 185 | END scalbln 186 | 187 | ENTER rint 188 | rintl: fldt 4(%esp) 189 | jmp 1f 190 | rintf: flds 4(%esp) 191 | jmp 1f 192 | rint: fldl 4(%esp) 193 | 1: frndint 194 | ret 195 | END rint 196 | 197 | ENTER sqrt 198 | sqrtl: fldt 4(%esp) 199 | jmp 1f 200 | sqrtf: flds 4(%esp) 201 | jmp 1f 202 | sqrt: fldl 4(%esp) 203 | 1: fsqrt 204 | ret 205 | END sqrt 206 | 207 | ENTER fabs 208 | fabsl: fldt 4(%esp) 209 | jmp 1f 210 | fabsf: flds 4(%esp) 211 | jmp 1f 212 | fabs: fldl 4(%esp) 213 | 1: fabs 214 | ret 215 | END fabs 216 | 217 | ENTER atan2 218 | atan2l: fldt 4(%esp) 219 | fldt 16(%esp) 220 | jmp 1f 221 | atan2f: flds 4(%esp) 222 | flds 8(%esp) 223 | jmp 1f 224 | atan2: fldl 4(%esp) 225 | fldl 12(%esp) 226 | 1: fpatan 227 | ret 228 | END atan2 229 | 230 | ENTER log2 231 | log2l: fldt 4(%esp) 232 | jmp 1f 233 | log2f: flds 4(%esp) 234 | jmp 1f 235 | log2: fldl 4(%esp) 236 | 1: fld1 237 | fxch 238 | fyl2x 239 | ret 240 | END log2 241 | 242 | ENTER exp2 243 | .type exp2x, @function 244 | exp2l: fldt 4(%esp) 245 | jmp exp2x 246 | exp2f: flds 4(%esp) 247 | jmp exp2x 248 | exp2: fldl 4(%esp) 249 | exp2x: fld %st(0) 250 | frndint 251 | fsubr %st,%st(1) 252 | fxch 253 | f2xm1 254 | fld1 255 | faddp 256 | fscale 257 | fstp %st(1) 258 | ret 259 | END exp2 260 | .size exp2x, . - exp2x 261 | 262 | ENTER pow 263 | powl: fldt 16(%esp) 264 | fldt 4(%esp) 265 | jmp 1f 266 | powf: flds 8(%esp) 267 | flds 4(%esp) 268 | jmp 1f 269 | pow: fldl 12(%esp) 270 | fldl 4(%esp) 271 | 1: fyl2x 272 | jmp exp2x 273 | END pow 274 | 275 | ENTER exp 276 | expl: fldt 4(%esp) 277 | jmp 1f 278 | expf: flds 4(%esp) 279 | jmp 1f 280 | exp: fldl 4(%esp) 281 | 1: fldl2e 282 | fmulp 283 | jmp exp2x 284 | END exp 285 | -------------------------------------------------------------------------------- /cgcabi.md: -------------------------------------------------------------------------------- 1 | % CGC Application Binary Interface 2 | 3 | # NAME 4 | CGCABI - CGC Application Binary Interface 5 | 6 | # SYNOPSIS 7 | \#include \ 8 | 9 | # DESCRIPTION 10 | 11 | This document details the Application Binary Interface (ABI) interface 12 | used by to CGC Challenge binaries to access system calls and the initial 13 | state of registers when a binary is loaded. 14 | 15 | The ABI and system calls have been designed to create a minimal number of 16 | system entry points that allows for the creation of CGC Challenge Binaries 17 | that reflect real world services and allow authors to inject memory corruption 18 | vulnerabilities consistent with the stated goals of the CGC program. 19 | 20 | Challenge binaries are run in an Intel 32bit Architecture (IA32) protected 21 | mode, flat memory model execution environment. 22 | 23 | # System Calls 24 | 25 | The following system calls may be present in a CGC binary execution 26 | environment. With few exceptions, these system calls adhere to the POSIX 27 | semantics associated with each corresponding system call as implemented on 28 | the Linux operating system. Each system call below is fully described in its 29 | own manual page. 30 | 31 | Name Number 32 | ---------- -------- 33 | _terminate 1 34 | transmit 2 35 | receive 3 36 | fdwait 4 37 | allocate 5 38 | deallocate 6 39 | random 7 40 | ---------- -------- 41 | 42 | A prototype for each system call is given in libcgc.h and a reference 43 | implementation can be found in libcgc.a. 44 | 45 | # System Call ABI 46 | 47 | The CGC application binary interface is specific to compatible x86-32 bit 48 | CGC execution environments. In order to invoke a CGC system call, the 49 | system call number must be placed in the eax register. Arguments to a 50 | system call function are passed via registers ebx, ecx, edx, esi, edi, 51 | and ebp as summarized in the following table: 52 | 53 | Register Purpose 54 | ---------- ------------------------------------------- 55 | eax Contains system call number 56 | ebx First argument to function 57 | ecx Second argument to function (if required) 58 | edx Third argument to function (if required) 59 | esi Fourth argument to function (if required) 60 | edi Fifth argument to function (if required) 61 | ebp Sixth argument to function (if required) 62 | 63 | Invocation of a system call function is accomplished through the use of 64 | the 'int 0x80' instruction. All system calls that return, return a 65 | status code in the eax register. A zero status indicates a successful 66 | system call. A non-zero status indicates an error and the specific 67 | error number is contained in the eax register. For system calls that 68 | return a value, the return value is provided to the caller via a caller 69 | supplied pointer parameter. See descriptions of individual system calls 70 | for more detailed information on both status codes and required 71 | parameters. If eax contains an invalid system call number upon entry to 72 | the kernel, the status ENOSYS shall be returned. 73 | 74 | # Invalid Instructions 75 | 76 | The following instructions have undefined behavior if used in a CGC 77 | Challenge Binary: rdpmc, rdrand, rdtsc, and rdtscp, and sysenter. 78 | 79 | # Signals 80 | 81 | Traditional POSIX signals are not supported by CGC Challenge Binaries. 82 | A CB process receiving a signal is killed by the kernel and a core(5) 83 | file may be produced. An exception to this rule is SIGPIPE. Normally, 84 | SIGPIPE sent to a process kills the process. A SIGPIPE results in a 85 | system call returning EPIPE. 86 | 87 | # Constants / Defines 88 | 89 | Several constants, structures, and macros are defined in libcgc.h 90 | for use by CBs. The definitions of these symbols may not be the 91 | same as the host operating system. 92 | 93 | Symbol 94 | ---------- ---------- 95 | EBADF 96 | EFAULT 97 | EINVAL 98 | ENOMEM 99 | ENOSYS 100 | EPIPE 101 | FD_CLR 102 | FD_ISSET 103 | _fd_mask 104 | fd_set 105 | FD_SET 106 | FD_SETSIZE 107 | FD_ZERO 108 | _NFDBITS 109 | NULL 110 | SIZE_MAX 111 | size_t 112 | SSIZE_MAX 113 | ssize_t 114 | STDERR 115 | STDIN 116 | STDOUT 117 | timeval 118 | 119 | # Initial State 120 | 121 | The initial state of the various processor and coprocessor registers are 122 | given below. 123 | 124 | ## Initial General Purpose Register State 125 | 126 | Register Value 127 | -------- ---------- 128 | EAX 0 129 | EBX 0 130 | ECX [note3] 131 | EDX 0 132 | EDI 0 133 | ESI 0 134 | ESP 0xbaaaaffc 135 | EBP 0 136 | EIP [note1] 137 | EFLAGS 0x202 138 | CS [note2] 139 | DS [note2] 140 | ES DS 141 | FS DS 142 | GS DS 143 | SS DS 144 | -------- ---------- 145 | 146 | note1: The EIP is set to the value of "c_entry" specified in the header 147 | of the CGC binary being loaded. 148 | 149 | note2: The values of the segment registers are not specified; however, 150 | the CS, DS, and SS registers will be set to correctly execute 151 | the CB and DS = ES = FS = GS = SS. 152 | 153 | note3: The ECX register contains a pointer to a page-aligned address 154 | filled with random data. The special flag page is read-only and it is 155 | not permitted to be deallocated. 156 | 157 | The value of the EFLAGS register means that interrupts are enabled 158 | (bit 9 set). Bit 1 is always set. 159 | 160 | ## Initial Floating Point Unit Register State 161 | 162 | Register Value 163 | ------------------- ------ 164 | Control 0x037f 165 | Status 0 166 | Tag 0xffff 167 | Opcode 0 168 | Instruction Pointer 0 169 | Data Pointer 0 170 | R0, R1, R2, R3 0 171 | R4, R5, R6, R7 0 172 | 173 | The Control register value is decoded as follows: 174 | rounding control = 0 (round closes to infinitely precise result, 175 | if equal, round to even least significant bit) 176 | precision control = 3 (double extended precision) 177 | all exceptions = 0 (masked) 178 | 179 | The tag register encoding just states that all fpu stack positions are 180 | empty (b'11 for all eight registers). 181 | 182 | ## Initial MMX register state 183 | 184 | The initial MMX register state is the same as the state of FPU since 185 | the registers are aliased to the same storage. 186 | 187 | ## Initial XMM Register State (SSE) 188 | 189 | Register Value 190 | --------------- ------ 191 | MXCSR 0x1f80 192 | XMM0 ... XMM15 0 193 | --------------- ------ 194 | 195 | The MXCSR is decoded as follows: 196 | flush to zero: disabled 197 | rounding control = 0 (same as FPU, above) 198 | all exceptions masked 199 | no exceptions currently flagged 200 | 201 | # Memory Layout 202 | 203 | When a CB is loaded, the PT_LOAD sections of the binary describe the 204 | layout of the binary in the 32bit virtual address space. The permissions 205 | of pages loaded by the binary are as specified (all pages are readable, 206 | but may also be executable and/or writeable). 207 | 208 | An initial stack is allocated for the process beginning from 0xbaaaaffc 209 | and going down. Stack pages are automatically allocated by the kernel 210 | on behalf of the process. All stack pages are readable, writable, and 211 | executable. Processes are allowed a maximum stack size of 8MB. 212 | 213 | The data segment (program text section, readonly section, bss, and 214 | read/write section), is limited to 1GB. This does not include memory 215 | allocated by the allocate(2) system call. 216 | 217 | There is no equivalent of argc, argv, envp normally provided by the 218 | kernel to a process. The stack region is filled with zero's as it 219 | is allocated and when execution begins at %eip, (%esp) = 0. 220 | 221 | # Math Functions 222 | 223 | The CGC library contains definitions for a variety of math functions 224 | for which acceleration is available on the processor but would require 225 | assembly language to access. Those functions are as follows. 226 | 227 | /* sine(x), where x is in radians */ 228 | float sinf(float); 229 | double sin(double); 230 | long double sinl(long double); 231 | 232 | /* cosine(x), where x is in radians */ 233 | float cosf(float); 234 | double cos(double); 235 | long double cosl(long double); 236 | 237 | /* tangent(x), where x is in radians */ 238 | float tanf(float); 239 | double tan(double); 240 | long double tanl(long double); 241 | 242 | /* arctangent(y, x): arctangent of y/x in radians */ 243 | float atan2f(float, float); 244 | double atan2(double, double); 245 | long double atan2l(long double, long double); 246 | 247 | /* square root */ 248 | float sqrtf(float); 249 | double sqrt(double); 250 | long double sqrtl(long double); 251 | 252 | /* round to integral value */ 253 | float rintf(float); 254 | double rint(double); 255 | long double rintl(long double); 256 | 257 | /* absolute value */ 258 | float fabsf(float); 259 | double fabs(double); 260 | long double fabsl(long double); 261 | 262 | /* remainder(x,y): returns r = x - n * y where */ 263 | /* n is the integer closest to x/y */ 264 | float remainderf(float, float); 265 | double remainder(double, double); 266 | long double remainderl(long double, long double); 267 | 268 | /* scalbn(x,y): scale x by power of 2**y: x * (2**y) */ 269 | float scalbnf(float, int); 270 | double scalbn(double, int); 271 | long double scalbnl(long double, int); 272 | float scalblnf(float, long int); 273 | double scalbln(double, long int); 274 | long double scalblnl(long double, long int); 275 | 276 | /* significand(x): mantissa of x */ 277 | float significandf(float); 278 | double significand(double); 279 | long double significandl(long double); 280 | 281 | /* base 2 logarithm */ 282 | float log2f(float); 283 | double log2(double); 284 | long double log2l(long double); 285 | 286 | /* natural logarithm */ 287 | float logf(float); 288 | double log(double); 289 | long double logl(long double); 290 | 291 | /* base 10 logarithm */ 292 | float log10f(float); 293 | double log10(double); 294 | long double log10l(long double); 295 | 296 | /* base 2 exponential */ 297 | float exp2f(float); 298 | double exp2(double); 299 | long double exp2l(long double); 300 | 301 | /* natural (base e) exponential */ 302 | float expf(float); 303 | double exp(double); 304 | long double expl(long double); 305 | 306 | /* pow(x,y) = x**y */ 307 | float powf(float, float); 308 | double pow(double, double); 309 | long double powl(long double, long double); 310 | 311 | # Other Functions 312 | 313 | In addition to the system calls and math functions, two additional 314 | functions are provided by the CGC ABI: setjmp() and longjmp(). These 315 | functions allow for saving processor state and restoring it at some 316 | point in the future. Their behavior is meant to mimic the behavior 317 | of these functions available in other operating systems. 318 | 319 | # CAVEATS 320 | 321 | The pow() functions are not conformant with C99. For instance, 322 | they return NaN for infinite exponents and for finite negative 323 | bases with finite integer exponents. 324 | 325 | # SEE ALSO 326 | 327 | cgc_executable_format(1), 328 | _terminate(2), 329 | transmit(2), 330 | receive(2), 331 | fdwait(2), 332 | allocate(2), 333 | deallocate(2), 334 | random(2), 335 | core(5). 336 | 337 | # FILES 338 | 339 | /usr/include/libcgc.h 340 | /usr/lib/libcgc.a 341 | --------------------------------------------------------------------------------