dslinux/user/perl/beos beos.c beosish.h nm.c
cayenne
dslinux_cayenne at user.in-berlin.de
Mon Dec 4 17:59:04 CET 2006
Update of /cvsroot/dslinux/dslinux/user/perl/beos
In directory antilope:/tmp/cvs-serv17422/beos
Added Files:
beos.c beosish.h nm.c
Log Message:
Adding fresh perl source to HEAD to branch from
--- NEW FILE: beosish.h ---
#ifndef PERL_BEOS_BEOSISH_H
#define PERL_BEOS_BEOSISH_H
#include "../unixish.h"
#undef waitpid
#define waitpid beos_waitpid
pid_t beos_waitpid(pid_t process_id, int *status_location, int options);
/* This seems to be protoless. */
char *gcvt(double value, int num_digits, char *buffer);
/* flock support, if available */
#ifdef HAS_FLOCK
#include <flock.h>
#undef close
#define close flock_close
#undef dup2
#define dup2 flock_dup2
#endif /* HAS_FLOCK */
#undef kill
#define kill beos_kill
int beos_kill(pid_t pid, int sig);
#undef sigaction
#define sigaction(sig, act, oact) beos_sigaction((sig), (act), (oact))
int beos_sigaction(int sig, const struct sigaction *act,
struct sigaction *oact);
#endif
--- NEW FILE: beos.c ---
#include "beos/beosish.h"
#undef waitpid
#undef kill
#undef sigaction
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <OS.h>
/* In BeOS 5.0 the waitpid() seems to misbehave in that the status
* has the upper and lower bytes swapped compared with the usual
* POSIX/UNIX implementations. To undo the surpise effect to the
* rest of Perl we need this wrapper. (The rest of BeOS might be
* surprised because of this, though.) */
pid_t beos_waitpid(pid_t process_id, int *status_location, int options) {
pid_t got = waitpid(process_id, status_location, options);
if (status_location)
*status_location =
(*status_location & 0x00FF) << 8 |
(*status_location & 0xFF00) >> 8;
return got;
}
/* BeOS kill() doesn't like the combination of the pseudo-signal 0 and
* specifying a process group (i.e. pid < -1 || pid == 0). We work around
* by changing pid to the respective process group leader. That should work
* well enough in most cases. */
int beos_kill(pid_t pid, int sig)
{
if (sig == 0) {
if (pid == 0) {
/* it's our process group */
pid = getpgrp();
} else if (pid < -1) {
/* just address the process group leader */
pid = -pid;
}
}
return kill(pid, sig);
}
/* sigaction() should fail, if trying to ignore or install a signal handler
* for a signal that cannot be caught or ignored. The BeOS R5 sigaction()
* doesn't return an error, though. */
int beos_sigaction(int sig, const struct sigaction *act,
struct sigaction *oact)
{
int result = sigaction(sig, act, oact);
if (result == 0 && act && act->sa_handler != SIG_DFL
&& act->sa_handler != SIG_ERR && (sig == SIGKILL || sig == SIGSTOP)) {
result = -1;
errno = EINVAL;
}
return result;
}
--- NEW FILE: nm.c ---
/* nm.c - a feeble shared-lib library parser
* Copyright 1997, 1998 Tom Spindler
* This software is covered under perl's Artistic license.
*/
/* $Id: nm.c,v 1.2 2006-12-04 16:59:02 dslinux_cayenne Exp $ */
#include <be/kernel/image.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
main(int argc, char **argv) {
char *path, *symname;
image_id img;
int32 n = 0;
volatile int32 symnamelen, symtype;
void *symloc;
if (argc != 2) { printf("more args, bozo\n"); exit(1); }
path = (void *) malloc((size_t) 2048);
symname = (void *) malloc((size_t) 2048);
if (!getcwd(path, 2048)) { printf("aiee!\n"); exit(1); }
if (!strcat(path, "/")) {printf("naah.\n"); exit (1); }
/*printf("%s\n",path);*/
if ('/' != argv[1][0]) {
if (!strcat(path, argv[1])) { printf("feh1\n"); exit(1); }
} else {
if (!strcpy(path, argv[1])) { printf("gah!\n"); exit(1); }
}
/*printf("%s\n",path);*/
img = load_add_on(path);
if (B_ERROR == img) {printf("Couldn't load_add_on() %s.\n", path); exit(2); }
symnamelen=2047;
while (B_BAD_INDEX != get_nth_image_symbol(img, n++, symname, &symnamelen,
&symtype, &symloc)) {
printf("%s |%s |GLOB %Lx | \n", symname,
((B_SYMBOL_TYPE_ANY == symtype) || (B_SYMBOL_TYPE_TEXT == symtype)) ? "FUNC" : "VAR ", symloc);
symnamelen=2047;
}
printf("number of symbols: %d\n", n);
if (B_ERROR == unload_add_on(img)) {printf("err while closing.\n"); exit(3); }
free(path);
return(0);
}
More information about the dslinux-commit
mailing list