Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

CarbonStdCLib.o Release Notes


 

CarbonStdCLib.o v3.8d3  [new 10/26/01]

The v3.8d3 StdCLib headers together with the static library CarbonStdCLib.o have been developed to provide Standard C Library functionality for Carbon applications running on both Mac OS 9 and Mac OS X, and to provide it in such a way that it is uniform across Mac OS 9 and Mac OS X. The first release of this library did not support all of the functionality that is provided by the Mac OS 9 StdCLib--this release v3.8d3 adds (almost) all of the functionality that was missing from v3.8d2. See the Release Notes for v3.8d2 below for a description of functionality, makefiles, known problems and behaviors which are different on OS 9 and OS X.

The added functionality for v3.8d3 CarbonStdCLib.o is summarized below:

<FSpio.h> - The FSp_≈ functions in the <FSpio.h> header are now supported.

<math.h> - The functions ecvt() and fcvt() are now supported.

<signal.h> - The functions signal() and raise() are now supported. Macro definitions have been modified for Carbon to coincide with the definitions for OS X. The signal() and raise() functions do the appropriate translations.

<stdio.h> - The function fsetfileinfo() is now supported.

<stdlib.h> - The function atexit() is now supported. The rand() function has been changed to match the OS X implementation, and correspodingly, the RAND_MAX value is now 0x7FFFFFFF. The vector memory management routines vec_calloc(), vec_free(), vec_malloc() and vec_realloc() are now supported. The long long support functions llabs(), lldiv(), strtoll(), strtoull() and atoll() are now supported.

The following bugs were fixed:

•  Fixed a bug in ConvertHFSPathToUnixPath() which caused paths such as "hd:my/foo" to be converted incorrectly to "/Volumes/hd/my/foo" (rather than "/Volumes/hd/my:foo") on OS X 10.0 [2567930].

•  Fixed a bug in ConvertHFSPathToUnixPath() which could cause POSIX paths to be encoded incorrectly.

•  Fixed a bug which could cause stdout and stderr not to be flushed appropriately.

•  Fixed a bug in localtime() (and, hence, gmtime()) where the tm_yday field could be miscalculated in the year 2000.

 

CarbonStdCLib.o v3.8d2  [new 7/30/01]

The v3.8d2 StdCLib headers together with the new static library CarbonStdCLib.o have been developed to provide Standard C Library functionality for Carbon applications running on both Mac OS 9 and Mac OS X, and to provide it in such a way that it is uniform across Mac OS 9 and Mac OS X. The first release of this library does not support all of the functionality that is provided by the Mac OS 9 StdCLib, but almost all of the functionality required by the ANSI C Standard is supported (notable exceptions are signal() and raise()). The headers make the unsupported functions invisible (guarded by CALL_NOT_IN_CARBON), and this will provide compile-time notice that a particular function is not supported (if the -proto strict option is used).

Most of the Standard C Library functions are linked directly to StdCLib on Mac OS 9, or to StdCLib on Mac OS X. Exceptions are the following:

creat()                fgetpos()                asctime()
faccess()              fileno()                 clock()
lseek()                fsetpos()                ctime()
open()                 setvbuf()                difftime()
                                                gmtime()
localeconv()           bsearch()                localtime()
setlocale()            _exit()                  mktime()
                       qsort()                  strftime()
                                                time()
                       setjmp()

As a result, all functions which take path names (e.g., fopen(), freopen(), open(), remove(), rename(), creat(), faccess() and unlink()) require that the appropriate style of path name be passed to the function. The library includes helper functions ConvertUnixPathToHFSPath() and ConvertHFSPathToUnixPath() (see <CarbonStdCLib.h>).

Each of the functions listed above will be discussed below.

creat() - The creat() function is not exported by StdCLib on Mac OS X. The implementation in CarbonStdCLib.o uses creat() in System.framework on Mac OS X.

faccess() - The faccess() function is not supported on Mac OS X. It is implemented for Mac OS X in CarbonStdCLib.o using open(), unlink() and rename().

lseek() - The lseek() function is not exported by StdCLib on Mac OS X. The implementation in CarbonStdCLib.o uses lseek() in System.framework on Mac OS X. The definition of off_t in <fcntl.h> has been changed for Carbon applications to be an Sint64 to match Mac OS X.

open() - The macros O_CREAT, O_TRUNC and O_EXCL are defined differently on Mac OS X. The implementation of open() in CarbonStdCLib.o translates these macros to the appropriate values for Mac OS X.

localeconv() - The struct lconv defined for Mac OS X differs from the same struct for Mac OS 9 in that the fields frac_digits and int_frac_digits are transposed. The implementation of localeconv() in CarbonStdCLib.o does the translation.

setlocale() - The category macros LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC and LC_TIME differ by one on Mac OS 9 and Mac OS X. The implementation of setlocale() in CarbonStdCLib.o performs the translation.

fgetpos() - The fpos_t type in <stdio.h> has been changed to be an SInt64 to match Mac OS X.

fsetpos() - The fpos_t type in <stdio.h> has been changed to be an SInt64 to match Mac OS X.

fileno() - The fileno() function is not exported by StdCLib on Mac OS X. The implementation in CarbonStdCLib.o uses fileno() in System.framework on Mac OS X.

setvbuf() - The macros _IOFBF, _IOLBF and _IONBF differ on Mac OS 9 and Mac OS X. The implementation of setvbuf() in CarbonStdCLib.o does the translation.

bsearch() and qsort() - Because of a problem in the handling of the function parameters on Mac OS X, the implementations of these functions are provided by the CarbonStdCLib.o library.

_exit() - The _exit() function is not exported by StdCLib on Mac OS X. The implementation in CarbonStdCLib.o uses _exit() in System.framework on Mac OS X.

setjmp() - The definition of the struct jmp_buf has been enlarged to satisfy the requirements of Mac OS X. The implementation of setjmp() in CarbonStdCLib.o (i.e., __lib_Glue_setjmp()) calls the appropriate setjmp() function on either Mac OS 9 or Mac OS X.

asctime(), clock(), ctime(), difftime(), gmtime(), localtime(), mktime() and strftime() - The implementation of the <time.h> functions in the CarbonStdCLib.o library is based upon the notion that time has its origin at January 1, 1970 and that time_t is a signed long value extending from December 13, 1901 to January 19, 2038. This is the view that Mac OS X takes, and is different from the Mac OS 9 view, which has an origin at January 1, 1904 and the time_t type is an unsigned long extending to February 6, 2040. The implementations of these functions perform the necessary translations. Also, CLOCKS_PER_SEC has been modified for Carbon applications to be 100 which matches Mac OS X. The implementation of clock() in CarbonStdCLib.o performs the conversion.

The Current Working Directory

Standard UNIX semantics are that the current UNIX working directory is inherited from the parent. This means that launching an application on Mac OS X that executes fopen("testresults", "w"); will open the testresults file in the directory that is current, not in the application's directory. You can change the current UNIX working directory to the application's directory as follows:

GetCurrentDirectoryUnixFormat( theUnixDirectory );
bsd_chdir( theUnixDirectory );

where GetCurrentDirectoryUnixFormat() locates the current directory using HGetVol(), creates an FSRef and then generates the path using FSRefMakePath().

Initialization and Termination

The CarbonStdCLib.o library contains data structures that must be initialized. In default operation, this is done lazily at the first function call that requires any of the necessary resources. You can force an early initialization by calling InitCarbonStdCLib(). You can terminate the library by calling TermCarbonStdCLib() when you will no longer be using CarbonStdCLib.o services. (See <CarbonStdCLib.h>.)

BSD Functions

The <CarbonStdCLib.h> header declares the functions bsd_chdir() and bsd_chmod() which correspond to the chdir() and chmod() functions on Mac OS X. These functions do nothing and return -1 on Mac OS 9.

Makefiles and CreateMake

To use CarbonStdCLib.o in a Carbon application, you must build your application linking with the StdCLib stub file (v3.4.3), StdCRuntime.o (v3.7) and CarbonLib. You cannot link with the newer StdCLib stub files (StdCLib_3.4.4, StdCLib_3.5 or StdCLib_3.7). The newer stub files have PEF versioning information which is incompatible with StdCLib on OS X. All of the exports of StdCLib on OS X are in the 3.4.3 version of the StdCLib stub file, so there is no advantage in linking with a newer version of the stub. CarbonStdCLib.o must appear before StdCLib in the list of link files:

LibFiles-PPC =                                 ∂
               "{PPCLibraries}"CarbonStdCLib.o ∂
               "{PPCLibraries}"StdCRuntime.o   ∂
               "{PPCLibraries}"PPCCRuntime.o   ∂
               …                               ∂
               "{SharedLibraries}"CarbonLib    ∂
               "{SharedLibraries}"StdCLib

An updated version of the CreateMake tool (v4.7.1d1) is available which will create an appropriate makefile for Carbon targets.

Known Problems

•  The current working directory is not inherited from the application’s directory on Mac OS X (10.0.4). [2614646]

•  The atexit() function is not supported for OS X in this release and should not have been exposed in the <stdlib.h> header file.

•  errno is non-zero at start-up. If you are using errno, then you should reset errno to 0 at start-up before proceeding.

•  lseek() and fseek() on Mac OS X (10.0.4) allow a negative offset from the beginning of the file. This puts the file into an unknown state, but it is not an error. [2703582].

•  The lseek() function on Mac OS 9 does not allow seeking past the end-of-file. [1322935] On Mac OS X, lseek() can seek past the end-of-file, and the next write() will extend the file; the intervening bytes are read back as 0.

•  A successful rewind() clears errno on Mac OS X (10.0.4). [2701753]

•  scanf() on long long data using %lld or %qd does not work on Mac OS X (10.0.4). [1685258, 2212532]

•  remove() does not remove directories on Mac OS X (10.0.4). [2408646]

•  A successful tmpnam() sets errno to ENOENT on Mac OS X (10.0.4). [2702547]

•  difftime() calculates the difference to time_t precision on Mac OS X (10.0.4) and therefore is incorrect if the difference is at least 231. That is, difftime(t1, t0) = (double)(t1 - t0) rather than (double)t1 - t0. [2709649]

•  localtime() and gmtime() miscalculate the tm_yday field on OS 9 if tm_year==100 (that is, the year is 2000), and tm_mon > 1 (March-December). The tm_yday field should be one larger because the year 2000 is a leap year. [2743951]

•  The rand() function on OS 9 returns a random value in the range [0 , 32767] and RAND_MAX is set to 32767. On OS X, the rand() function returns a value in the range [0 , 2147483647] and RAND_MAX is set to 0x7FFFFFFF. The <stdlib.h> header file still has RAND_MAX set to 32767, but this is incorrect for OS X.

Behaviors That Differ on Mac OS 9 and Mac OS X

•  fflush() on a read-only file or on a closed file is an error on Mac OS X.

•  rename(old, new) works on Mac OS X even if new exists, whereas on Mac OS 9 it does not. The correct behavior is the Mac OS X behavior.

•  unlink() on an open file works on Mac OS X because it decrements the link count—the file is deleted if its link count is zero when it is closed. This behavior differs from Mac OS 9 unlink() which will return an error when asked to unlink() an open file. remove() on an open file works on Mac OS X as it is a call to unlink().

•  Several of the conversion specifiers for strftime() produce results in different formats on Mac OS X than on Mac OS 9:

           Mac OS X                     Mac OS 9
       -----------------   -----------------------------------
%c:    07/04/01 00:00:01   12:00:01 AM Wednesday, July 4, 2001
%p:    AM                   AM (with leading space)
%x:    07/04/01            Wednesday, July 4, 2001
%X:    00:00:01            12:00:01 AM

 
Back to MPW Home Page
Back to MPW Home Page