Subdirectory g++ contains C++ shared library helper routines.

This commit is contained in:
pk 1994-01-05 21:05:11 +00:00
parent 525fbd9129
commit e5ea148320
3 changed files with 77 additions and 2 deletions

View File

@ -1,5 +1,5 @@
# $Id: Makefile,v 1.3 1993/12/04 22:39:21 cgd Exp $
# $Id: Makefile,v 1.4 1994/01/05 21:05:11 pk Exp $
SUBDIR= ${MACHINE_ARCH}
SUBDIR= ${MACHINE_ARCH} g++
.include <bsd.subdir.mk>

18
lib/csu/g++/Makefile Normal file
View File

@ -0,0 +1,18 @@
# $Id: Makefile,v 1.1 1994/01/05 21:05:33 pk Exp $
CFLAGS+= -DLIBC_SCCS
OBJS= c++rt0.o
all: ${OBJS}
c++rt0.o: c++rt0.c
${CC} ${CFLAGS} -c ${.ALLSRC}
${LD} -x -r ${.TARGET}
mv a.out ${.TARGET}
install:
install -d -o ${BINOWN} -g ${BINGRP} -m 0755 ${DESTDIR}/usr/lib
install ${COPY} -o ${BINOWN} -g ${BINGRP} -m 444 ${OBJS} \
${DESTDIR}/usr/lib
.include <bsd.prog.mk>

57
lib/csu/g++/c++rt0.c Normal file
View File

@ -0,0 +1,57 @@
/*
* CRT module for GNU C++ compiles shared libraries.
*
* $Id: c++rt0.c,v 1.1 1994/01/05 21:05:37 pk Exp $
*/
void (*__CTOR_LIST__[2])(void);
void (*__DTOR_LIST__[2])(void);
/* Run all the global destructors on exit from the program. */
static void
__do_global_dtors(void)
{
unsigned long nptrs = (unsigned long) __DTOR_LIST__[0];
unsigned i;
/*
* Some systems place the number of pointers
* in the first word of the table.
* On other systems, that word is -1.
* In all cases, the table is null-terminated.
*/
/* If the length is not recorded, count up to the null. */
if (nptrs == -1)
for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);
/* GNU LD format. */
for (i = nptrs; i >= 1; i--)
__DTOR_LIST__[i] ();
}
static void
__do_global_ctors(void)
{
void (**p)(void);
for (p = __CTOR_LIST__ + 1; *p; )
(**p++)();
}
extern void __init() asm(".init");
void
__init(void)
{
static int initialized = 0;
if (!initialized) {
initialized = 1;
__do_global_ctors();
atexit(__do_global_dtors);
}
}