add directory gnu
This commit is contained in:
32
gnu/glibc/glibc-1.03/setjmp/Makefile
Normal file
32
gnu/glibc/glibc-1.03/setjmp/Makefile
Normal file
@@ -0,0 +1,32 @@
|
||||
# Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
# This file is part of the GNU C Library.
|
||||
|
||||
# The GNU C Library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of the
|
||||
# License, or (at your option) any later version.
|
||||
|
||||
# The GNU C Library 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
|
||||
# Library General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
# Cambridge, MA 02139, USA.
|
||||
|
||||
#
|
||||
# Makefile for setjmp/longjmp routines
|
||||
#
|
||||
subdir := setjmp
|
||||
|
||||
headers := setjmp.h jmp_buf.h
|
||||
|
||||
routines := longjmp setjmp siglongjmp sigsetjmp \
|
||||
_setjmp _longjmp __longjmp
|
||||
|
||||
tests := tst-setjmp
|
||||
|
||||
|
||||
include ../Rules
|
||||
26
gnu/glibc/glibc-1.03/setjmp/_longjmp.c
Normal file
26
gnu/glibc/glibc-1.03/setjmp/_longjmp.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <gnu-stabs.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#undef _longjmp
|
||||
|
||||
function_alias(_longjmp, __longjmp, void, (env, val),
|
||||
DEFUN(_longjmp, (env, val), CONST jmp_buf env AND int val))
|
||||
26
gnu/glibc/glibc-1.03/setjmp/_setjmp.c
Normal file
26
gnu/glibc/glibc-1.03/setjmp/_setjmp.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <gnu-stabs.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#undef _setjmp
|
||||
|
||||
function_alias(_setjmp, __setjmp, int, (env),
|
||||
DEFUN(_setjmp, (env), jmp_buf env))
|
||||
26
gnu/glibc/glibc-1.03/setjmp/longjmp.c
Normal file
26
gnu/glibc/glibc-1.03/setjmp/longjmp.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <gnu-stabs.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#undef longjmp
|
||||
|
||||
function_alias_void(longjmp, __longjmp, (env, val),
|
||||
DEFUN(longjmp, (env, val), CONST jmp_buf env AND int val))
|
||||
108
gnu/glibc/glibc-1.03/setjmp/setjmp.h
Normal file
108
gnu/glibc/glibc-1.03/setjmp/setjmp.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
/*
|
||||
* ANSI Standard: 4.6 NON-LOCAL JUMPS <setjmp.h>
|
||||
*/
|
||||
|
||||
#ifndef _SETJMP_H
|
||||
|
||||
#define _SETJMP_H 1
|
||||
#include <features.h>
|
||||
|
||||
/* Get the machine-dependent definition of `__jmp_buf'. */
|
||||
#include <jmp_buf.h>
|
||||
|
||||
#ifndef __NORETURN
|
||||
#ifdef __GNUC__
|
||||
/* The `volatile' keyword tells GCC that a function never returns. */
|
||||
#define __NORETURN __volatile
|
||||
#else /* Not GCC. */
|
||||
#define __NORETURN
|
||||
#endif /* GCC. */
|
||||
#endif /* __NORETURN not defined. */
|
||||
|
||||
/* Jump to the environment saved in ENV, making the
|
||||
setjmp call there return VAL, or 1 if VAL is 0. */
|
||||
extern __NORETURN void EXFUN(__longjmp, (CONST __jmp_buf __env, int __val));
|
||||
extern __NORETURN void EXFUN(longjmp, (CONST __jmp_buf __env, int __val));
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
#define longjmp(env, val) __longjmp((env), (val))
|
||||
#endif /* Optimizing. */
|
||||
|
||||
/* Set ENV to the current position and return 0. */
|
||||
extern int EXFUN(__setjmp, (__jmp_buf __env));
|
||||
/* The ANSI standard says `setjmp' is a macro. */
|
||||
#define setjmp(env) __setjmp(env)
|
||||
|
||||
|
||||
#ifdef __USE_POSIX
|
||||
#define __need_sigset_t
|
||||
#include <signal.h>
|
||||
|
||||
/* Calling environment, plus possibly a saved signal mask. */
|
||||
typedef struct
|
||||
{
|
||||
__jmp_buf __jmpbuf; /* Calling environment. */
|
||||
sigset_t __sigmask; /* Saved signal mask. */
|
||||
unsigned int __savemask:1; /* Saved the signal mask? */
|
||||
} sigjmp_buf[1];
|
||||
|
||||
/* Store the calling environment in ENV, also saving the
|
||||
signal mask if SAVEMASK is nonzero. Return 0. */
|
||||
extern int EXFUN(sigsetjmp, (sigjmp_buf __env, int __savemask));
|
||||
|
||||
/* Jump to the environment saved in ENV, making the
|
||||
sigsetjmp call there return VAL, or 1 if VAL is 0.
|
||||
Restore the signal mask if that sigsetjmp call saved it. */
|
||||
extern __NORETURN void EXFUN(siglongjmp, (CONST sigjmp_buf __env, int __val));
|
||||
#endif /* Use POSIX. */
|
||||
|
||||
|
||||
#ifdef __USE_BSD
|
||||
extern __NORETURN void EXFUN(_longjmp, (CONST __jmp_buf __env, int __val));
|
||||
extern int EXFUN(_setjmp, (__jmp_buf __env));
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
#define _longjmp(env, val) longjmp((env), (val))
|
||||
#define _setjmp(env) __setjmp(env)
|
||||
#endif /* Optimizing. */
|
||||
#endif /* Use BSD. */
|
||||
|
||||
#ifdef __FAVOR_BSD
|
||||
|
||||
/* BSD defines `setjmp' and `longjmp' to save and restore the set of
|
||||
blocked signals. For this, `jmp_buf' must be what POSIX calls
|
||||
`sigjmp_buf', which includes that information. */
|
||||
typedef sigjmp_buf jmp_buf;
|
||||
|
||||
#undef setjmp
|
||||
#define setjmp(env) sigsetjmp((env), 1)
|
||||
|
||||
#undef longjmp
|
||||
#define longjmp(env, val) siglongjmp((env), (val))
|
||||
|
||||
#else /* Don't favor BSD. */
|
||||
|
||||
/* A `jmp_buf' really is a `jmp_buf'. Oh boy. */
|
||||
typedef __jmp_buf jmp_buf;
|
||||
|
||||
#endif /* Favor BSD. */
|
||||
|
||||
#endif /* setjmp.h */
|
||||
36
gnu/glibc/glibc-1.03/setjmp/siglongjmp.c
Normal file
36
gnu/glibc/glibc-1.03/setjmp/siglongjmp.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
/* Set the signal mask to the one specified in ENV, and jump
|
||||
to the position specified in ENV, causing the sigsetjmp
|
||||
call there to return VAL, or 1 if VAL is 0. */
|
||||
__NORETURN
|
||||
void
|
||||
DEFUN(siglongjmp, (env, val), CONST sigjmp_buf env AND int val)
|
||||
{
|
||||
if (env[0].__savemask)
|
||||
(void) sigprocmask(SIG_SETMASK, &env[0].__sigmask, (sigset_t *) NULL);
|
||||
|
||||
longjmp(env[0].__jmpbuf, val);
|
||||
}
|
||||
37
gnu/glibc/glibc-1.03/setjmp/sigsetjmp.c
Normal file
37
gnu/glibc/glibc-1.03/setjmp/sigsetjmp.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
/* Store the calling environment in ENV, also saving the
|
||||
signal mask if SAVEMASK is nonzero. Return 0. */
|
||||
int
|
||||
DEFUN(sigsetjmp, (env, savemask), sigjmp_buf env AND int savemask)
|
||||
{
|
||||
if (savemask)
|
||||
env[0].__savemask = sigprocmask(SIG_BLOCK, (sigset_t *) NULL,
|
||||
&env[0].__sigmask) == 0;
|
||||
else
|
||||
env[0].__savemask = 0;
|
||||
|
||||
return(setjmp(env[0].__jmpbuf));
|
||||
}
|
||||
61
gnu/glibc/glibc-1.03/setjmp/tst-setjmp.c
Normal file
61
gnu/glibc/glibc-1.03/setjmp/tst-setjmp.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static jmp_buf env;
|
||||
static int last_value = -1, lose = 0;
|
||||
|
||||
void
|
||||
DEFUN(jump, (val), int val)
|
||||
{
|
||||
longjmp(env, val);
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN_VOID(main)
|
||||
{
|
||||
int value;
|
||||
|
||||
value = setjmp(env);
|
||||
if (value != last_value + 1)
|
||||
{
|
||||
fputs("Shouldn't have ", stdout);
|
||||
lose = 1;
|
||||
}
|
||||
last_value = value;
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
puts("Saved environment.");
|
||||
jump(0);
|
||||
default:
|
||||
printf("Jumped to %d.\n", value);
|
||||
if (value < 10)
|
||||
jump(value + 1);
|
||||
}
|
||||
|
||||
if (lose || value != 10)
|
||||
puts("Test FAILED!");
|
||||
else
|
||||
puts("Test succeeded!");
|
||||
exit(lose ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
Reference in New Issue
Block a user