libCom: Fix sysAtReboot registration on vxWorks 6.8+

Removed C++ static constructor, do it from epicsThreadInit()
This commit is contained in:
Andrew Johnson
2013-04-24 12:52:05 -05:00
parent 5bc15b72a1
commit 7e347b2de9
3 changed files with 19 additions and 22 deletions

View File

@@ -13,6 +13,13 @@
<!-- Insert new items immediately below here ... -->
<h4>VxWorks sysAtReboot Registration</h4>
<p>The increasing intelligence of the GNU compiler and linker broke the method
that was being used by the VxWorks code to register a reboot hook that can close
down TCP connections nicely before the network stack gets disabled. This has
been fixed and no longer uses a C++ static contructor to execute that code.</p>
<h4>IOCS_APPL_TOP and INSTALL_LOCATION</h4>
<p>An IOC application that sets INSTALL_LOCATION in its configure/CONFIG_SITE

View File

@@ -1,10 +1,9 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* Copyright (c) 2013 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* atReboot.cpp */
@@ -16,34 +15,28 @@
#include "epicsDynLink.h"
#include "epicsExit.h"
/* osdThread references atRebootExtern just to make this module load*/
int atRebootExtern;
extern "C" {
typedef int (*sysAtReboot_t)(void(func)(void));
class atRebootRegister {
public:
atRebootRegister();
};
atRebootRegister::atRebootRegister()
void atRebootRegister(void)
{
STATUS status;
sysAtReboot_t sysAtReboot;
SYM_TYPE type;
status = symFindByNameEPICS(sysSymTbl, "_sysAtReboot",
(char **)&sysAtReboot, &type);
(char **)&sysAtReboot, &type);
if (status == OK) {
status = sysAtReboot(epicsExitCallAtExits);
if (status != OK) {
printf("atReboot: sysAtReboot returned error %d\n", status);
}
} else {
printf("BSP routine sysAtReboot() not found, epicsExit() will not be\n"
"called by reboot. For reduced functionality, call\n"
" rebootHookAdd(epicsExitCallAtExits)\n");
printf("BSP routine sysAtReboot() not found, epicsExit() will not be\n"
"called by reboot. For reduced functionality, call\n"
" rebootHookAdd(epicsExitCallAtExits)\n");
}
}
static atRebootRegister atRebootRegisterObj;
}

View File

@@ -43,12 +43,8 @@
static const unsigned stackSizeTable[epicsThreadStackBig+1] =
{4000*ARCH_STACK_FACTOR, 6000*ARCH_STACK_FACTOR, 11000*ARCH_STACK_FACTOR};
/*The following forces atReboot to be loaded*/
extern int atRebootExtern;
static struct pext {
int *pExtern;
struct pext *pext;
} pext = {&atRebootExtern, &pext};
/* This routine is found in atReboot.cpp */
extern void atRebootRegister(void);
/* definitions for implementation of epicsThreadPrivate */
static void **papTSD = 0;
@@ -93,6 +89,7 @@ static void epicsThreadInit(void)
epicsThreadOnceMutex = semMCreate(
SEM_DELETE_SAFE|SEM_INVERSION_SAFE|SEM_Q_PRIORITY);
assert(epicsThreadOnceMutex);
atRebootRegister();
}
lock = 0;
}