Code Search for Developers
 
 
  

linux-syscalls1.c from Gdb at Krugle


Show linux-syscalls1.c syntax highlighted

/** Linux system call interface.
 * Written by Shaun Jackman <sjackman@gmail.com>.
 * Copyright 2006 Pathway Connectivity
 *
 * Permission to use, copy, modify, and distribute this software
 * is freely granted, provided that this notice is preserved.
 */

#include <errno.h>
#include <stdint.h>

extern char _end[];
static void *curbrk = _end;

extern void *_brk(void *addr);

int brk(void *addr)
{
	void *newbrk;
	if (curbrk == addr)
		return 0;
	newbrk = _brk(addr);
	curbrk = newbrk;
	if (newbrk < addr) {
		errno = ENOMEM;
		return -1;
	}
	return 0;
}

void *_sbrk(intptr_t incr)
{
	void *oldbrk = curbrk;
	if (brk(oldbrk + incr) == -1)
		return (void *)-1;
	return oldbrk;
}

void *sbrk(intptr_t incr) __attribute__((alias("_sbrk")));

int _set_errno(int n)
{
	if (n < 0) {
		errno = -n;
		return -1;
	}
	return n;
}

#include <sys/wait.h>

struct rusage;

pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);

pid_t _wait(int *status)
{
	return wait4(-1, status, 0, NULL);
}

pid_t waitpid(pid_t pid, int *status, int options)
{
	return wait4(pid, status, options, NULL);
}

extern int _reboot(int magic, int magic2, int flag, void *arg);

int reboot(int flag)
{
	return _reboot(0xfee1dead, 0x28121969, flag, NULL);
}




See more files for this project here

Gdb

GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it crashed.

Project homepage: http://sources.redhat.com/gdb/
Programming language(s): Assembly,C,C++,Expect
License: other

  Makefile.in
  _exit.c
  _kill.c
  aclocal.m4
  coff-iq80310.specs
  coff-pid.specs
  coff-rdimon.specs
  coff-rdpmon.specs
  coff-redboot.ld
  coff-redboot.specs
  configure
  configure.in
  crt0.S
  elf-iq80310.specs
  elf-linux.specs
  elf-pid.specs
  elf-rdimon.specs
  elf-rdpmon.specs
  elf-redboot.ld
  elf-redboot.specs
  libcfunc.c
  linux-crt0.c
  linux-syscall.h
  linux-syscalls0.S
  linux-syscalls1.c
  redboot-crt0.S
  redboot-syscalls.c
  swi.h
  syscall.h
  syscalls.c
  trap.S