*BSD News Article 56054


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!lll-winken.llnl.gov!taco.cc.ncsu.edu!crazytrain.eos.ncsu.edu!not-for-mail
From: kpneal@eos.ncsu.edu (Kevin P. Neal)
Newsgroups: comp.unix.bsd.netbsd.misc
Subject: Thread safe errno-clone?
Date: 27 Nov 1995 07:49:23 GMT
Organization: North Carolina State University
Lines: 25
Message-ID: <49bqi3$4du@taco.cc.ncsu.edu>
NNTP-Posting-Host: crazytrain.eos.ncsu.edu
X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]

I'm working on integrating RCS into a library. This is a bit of
a big task, taking all that old code, rewriting much of it,
and generally restructuring it to be a library.

Here is the problem. Many of the .c files have error conditions in them
that it reports via printf(). This is unacceptable in a library.
I need a way to get the errors back to the user application. I was 
looking at the system errno concept and thought about integrating
something like this into the rcs library. You know, parts would
return NULL or -1 or something to indicate error, then you call
rcs_get_error_code() or somesuch to retrieve the error code.
(Then call rcs_get_error_txt(errorcode) to get the ASCII version of
the error). 

I want the library to be thread-safe. This would seem to rule out a
global variable for this purpose, because at least one light-weight
thread library uses the same global data section for all of it's
threads (isn't that what a lwt is?). So how can I make some sort
of rcs_set_global_error() that is thread proof? 

-- 
XCOMM --------------------------------------------------------
XCOMM Kevin P. Neal, Sophomore CSC/CPE     kpneal@eos.ncsu.edu 
XCOMM North Carolina State University      kevinneal@bix.com
XCOMM --------------------------------------------------------