sigset_t SigON;
#define g_s(x) (1<<(x-1))
int main( int argc, char **argv )
{
struct timeval now_time;
int port;
sigfillset( &SigON );
sigdelset( &SigON, SIGALRM );
sigdelset( &SigON, SIGSEGV );
sigdelset( &SigON, SIGTERM );
sigdelset( &SigON, SIGINT );
sigdelset( &SigON, SIGUSR1 );
sigdelset( &SigON, SIGUSR2 );
sigdelset( &SigON, SIGQUIT );
sigdelset( &SigON, SIGFPE );
sigprocmask(SIG_SETMASK,&SigON,0);
void bug_close(int num)
{
signal(SIGSEGV,rutina_senyal);
fprintf(stderr,"BUG-CLOSE:f_close ha generado un SIG_SEGV!!!!\n");
__asm__("movl _dirbp,%eax");
__asm__("movl $6,%ecx");
__asm__(".buc:");
__asm__("movl %ebp,%esp");
__asm__("popl %ebp");
__asm__("decl %ecx");
__asm__("je .fin");
__asm__("cmpl %ebp,%eax");
__asm__("jne .buc");
__asm__(".fin:");
__asm__("ret");
}
void bug_malloc(int num)
{
signal(SIGSEGV,rutina_senyal);
fprintf(stderr,"BUG-MALLOC:un malloc ha generado un SIG_SEGV!!!!\n");
__asm__("movl _dirbp,%eax");
__asm__("movl $6,%ecx");
__asm__(".buc2:");
__asm__("movl %ebp,%esp");
__asm__("popl %ebp");
__asm__("decl %ecx");
__asm__("je .fin2");
__asm__("cmpl %ebp,%eax");
__asm__("jne .buc2");
__asm__(".fin2:");
__asm__("ret");
}
int retc;
int f_close(FILE *f)
{
retc=-1;
COUNT_OPEN–;
if (COUNT_OPEN<0)
{
fprintf(stderr,"BUG:Mas closes que Opens!!!\n");
COUNT_OPEN=0;
}
signal(SIGSEGV,bug_close);
__asm__("pushal");
__asm__("movl %esp,_dirp");
__asm__("movl %ebp,_dirbp");
retc=fclose(f);
__asm__("movl _dirp,%esp");
__asm__("popal");
signal(SIGSEGV,rutina_senyal);
return retc;
}
void *retm;
void *m_alloc(size_t t)
{
retm=0;
signal(SIGSEGV,bug_malloc);
__asm__("pushal");
__asm__("movl %esp,_dirp");
__asm__("movl %ebp,_dirbp");
retm=calloc(1,t);
__asm__("movl _dirp,%esp");
__asm__("popal");
signal(SIGSEGV,rutina_senyal);
return retm;
}
Out of curiosity I tried to compile an old code that sent me a friend. This code has been modified to compile with gcc-4.x, but…
[root@server src]# make
g++48 -Wno-write-strings -g -o .obj/act_comm.o -c act_comm.cpp
g++48 -Wno-write-strings -g -o .obj/act_info.o -c act_info.cpp
g++48 -Wno-write-strings -g -o .obj/act_move.o -c act_move.cpp
g++48 -Wno-write-strings -g -o .obj/act_obj.o -c act_obj.cpp
g++48 -Wno-write-strings -g -o .obj/act_wiz.o -c act_wiz.cpp
g++48 -Wno-write-strings -g -o .obj/buffer.o -c buffer.cpp
g++48 -Wno-write-strings -g -o .obj/cajas.o -c cajas.cpp
g++48 -Wno-write-strings -g -o .obj/clean.o -c clean.cpp
g++48 -Wno-write-strings -g -o .obj/comm.o -c comm.cpp
comm.cpp: In function int main(int, char**):
comm.cpp:218:37: error: cannot convert unsigned int* to const sigset_t* {aka const __sigset_t*} for argument 2 to int sigprocmask(int, const sigset_t*, sigset_t*)
sigprocmask(SIG_SETMASK,&SigON,0);
^
make: *** [.obj/comm.o] Error 1
The part of code is:
Someone can help me? I use a 64-bit pc.
If I comment the line
sigprocmask(SIG_SETMASK,&SigON,0);
the compiler returns an error about 64-bit support and does not create the executable.