summaryrefslogtreecommitdiffstats
path: root/src/include/k5-platform.h
Commit message (Collapse)AuthorAgeFilesLines
* Now that we have support for conditionally exporting symbols from the supportKen Raeburn2008-10-151-74/+5
| | | | | | library, use that for the [v]asprintf replacement functions when needed. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20871 dc483132-0cff-0310-8789-dd5450dbe970
* Fix vasprintf signed/unsigned mix; separate out duplicated error paths; pull ↵Ken Raeburn2008-08-291-26/+40
| | | | | | success return path out of guts of loop git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20703 dc483132-0cff-0310-8789-dd5450dbe970
* Merge from branch sun-ipropKen Raeburn2008-06-241-2/+5
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20465 dc483132-0cff-0310-8789-dd5450dbe970
* Implement SWAP16 for Mac without compiler warningKen Raeburn2007-12-221-1/+9
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20194 dc483132-0cff-0310-8789-dd5450dbe970
* On Windows, UINT64_MAX isn't defined; define itKevin Koch2007-11-151-0/+4
| | | | | | | | TargetVersion: 1.7 Component: krb5-libs Ticket: 5594 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20166 dc483132-0cff-0310-8789-dd5450dbe970
* On Mac, include TargetConditionals.h and architecture/byte_order.h,Ken Raeburn2007-10-291-0/+28
| | | | | | | | | and use OSSwapInt{16,32,64} for SWAP* macros. Add k5_htonll and k5_ntohll functions. (Implementation assumes the swapping is its own reverse on all platforms we support.) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20150 dc483132-0cff-0310-8789-dd5450dbe970
* Set close-on-exec flag in most places where file descriptors areKen Raeburn2007-10-221-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | opened in our libraries (in case another application thread spawns a new process) and in the KDC programs (in case a plugin library spawns a new process). Checked calls to: open fopen THREEPARAMOPEN mkstemp socket accept dup dup2 pipe. In: util lib plugins kdc kadmin/server krb524. The various programs are less critical than the libraries, as any well-written plugin that spawns a new process should close all file descriptors it doesn't need to communicate with the new process. This approach also isn't bulletproof, as the call to set the close-on-exec flag is necessarily a separate call from creating the file descriptor, and the fork call could happen in between them. So plugins should be careful regardless of this patch; it will only reduce the window of potential lossage should a plugin be poorly written. (AFAIK there are currently no plugins that spawn processes where this would be a problem.) Update dependencies. ticket: 5561 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20143 dc483132-0cff-0310-8789-dd5450dbe970
* Define snprintf along with vsnprintf for WindowsKen Raeburn2007-08-011-0/+11
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19742 dc483132-0cff-0310-8789-dd5450dbe970
* Provide {,v}asprintf prototypes if neededKen Raeburn2007-07-271-0/+15
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19735 dc483132-0cff-0310-8789-dd5450dbe970
* Under gcc, declare k5_v?asprintf with format attributeKen Raeburn2007-06-291-0/+8
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19654 dc483132-0cff-0310-8789-dd5450dbe970
* For Win32 environment, define CAN_COPY_VA_LIST, and define an inlineKen Raeburn2007-06-271-1/+21
| | | | | | | version of vsnprintf using the MS versions. (Apparently no need for plain snprintf just yet.) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19644 dc483132-0cff-0310-8789-dd5450dbe970
* If mkstemp is missing, define the mkstemp macro is k5-platform.h, not autoconf.hKen Raeburn2007-06-271-0/+1
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19643 dc483132-0cff-0310-8789-dd5450dbe970
* Add the libdb2 type-existence tests to the top-level configure script.Ken Raeburn2007-06-201-0/+1
| | | | | | | | | | | Replace the generated header files in db2 with static ones that include autoconf.h and make decisions based on the macros defined there. Omit some tests that test for things we assume now, like "const" working and "size_t" being defined. Update dependencies. The libdb2 configure script now generates no header files. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19605 dc483132-0cff-0310-8789-dd5450dbe970
* Move (BSD-licensed) mkstemp from libdb2 to libkrb5support, and renameKen Raeburn2007-06-201-0/+3
| | | | | | | | | | | | | the function to krb5int_mkstemp. Generate the symbol export list for libkrb5support at build time. Declare krb5int_mkstemp in k5-platform.h. Change cc_file.c to use mkstemp unconditionally. Make libdb2.so (built for testing only) link against the libkrb5support, and use krb5int_mkstemp if mkstemp is not available. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19600 dc483132-0cff-0310-8789-dd5450dbe970
* provide asprintf functionality for internal useKen Raeburn2007-06-201-3/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I plan to use asprintf in some gssapi error-message management routines, so let's make sure we have the functionality available, implementing it locally if necessary. This implementation assumes vsnprintf is available, an assumption that the support library is already making at the moment. Since this implementation requires calling vsnprintf potentially multiple times with the same va_list, use va_copy if it's available, or provide a hack version (which should work okay if va_list is a scalar or array type that requires no other special handling, and if va_end does nothing interesting, which is usually the case) if the compiler doesn't provide it. I also changed a couple bits of code to use asprintf, to make sure we exercise our implementation in testing. (C99 requires vsnprintf and va_copy; vasprintf is a GNU/BSD extension, but an oh so useful one....) * configure.in: Check for va_copy, or if va_list objects can be simply assigned. Define HAS_VA_COPY and CAN_COPY_VA_LIST as appropriate. * include/k5-platform.h: Define a va_copy macro if the compiler doesn't provide it. * include/k5-platform.h: If vsnprintf isn't available from the OS, abort compilation. If vasprintf isn't available from the OS, provide k5_{v,}asprintf based on vsnprintf and define {v,}asprintf macros. * lib/krb5/keytab/t_keytab.c (do_test): Use asprintf. * util/support/errors.c (krb5int_vset_error): Use asprintf unconditionally. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19595 dc483132-0cff-0310-8789-dd5450dbe970
* Use "unsigned __int{16,32}" types for Windows in load_{16,32}_n, per KevinKen Raeburn2007-03-141-0/+8
| | | | | | ticket: 5425 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19227 dc483132-0cff-0310-8789-dd5450dbe970
* * include/k5-platform.h: Add load_{16,32,64}_n for loading values fromKen Raeburn2007-03-141-0/+24
| | | | | | | | | | | (possibly unaligned) memory in native order. * lib/krb5/krb/get_in_tkt.c (krb5_get_init_creds): Fetch four random bytes from the crypto library and generate a 31-bit (non-negative) nonce, instead of using the timestamp. ticket: 5425 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19223 dc483132-0cff-0310-8789-dd5450dbe970
* POSIX allows getpwnam_r and getpwuid_r to return 0 (success) even if theRuss Allbery2006-06-131-4/+6
| | | | | | | | | | | | | username or UID could not be found, in which case OUT will be set to NULL. Elsewhere, code assumes that if k5_getpwnam_r or k5_getpwuid_r returns 0, OUT is non-NULL. Check whether OUT is NULL and adjust the return value accordingly in the k5_getpw{nam,uid}_r wrappers. Ticket: 3490 Version_Reported: 1.4.3 Component: krb5-libs git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18121 dc483132-0cff-0310-8789-dd5450dbe970
* Enable compilation of little-endian unaligned load/store helperKen Raeburn2006-03-081-2/+0
| | | | | | | functions in k5-platform.h, and use them in kdb encoding/decoding macros. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17710 dc483132-0cff-0310-8789-dd5450dbe970
* * k5-platform.h: Include endian.h if it's available, or machine/endian.h ifKen Raeburn2005-06-151-75/+120
| | | | | | | | | | | it's available. Include byteswap.h if available. (K5_LE, K5_BE): Define based on endianness macros from header files, if available. Only do the architecture tests if this fails. (SWAP16, SWAP32, SWAP64): Define if byteswap.h and bswap_16 are available. ({load,store}_{16,32,64}_le): Disable building of little-endian versions, which aren't currently used. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17239 dc483132-0cff-0310-8789-dd5450dbe970
* Use GCC's packed-structure support to try to optimize unaligned loads andKen Raeburn2005-06-091-7/+122
| | | | | | | | | | | | | | | | | | | stores of values. (E.g., on x86, gcc will emit a word load or store regardless of alignment; on sparc or alpha, it will do aligned word accesses. The old C code does byte operations and arithmetic, always.) Tested in crypto code on x86, sparc, and amd64. * k5-platform.h (load_*): Change argument type to point to const. (K5_BE, K5_LE): New macros, defined based on architecture macros for certain big-endian and little-endian platforms, respectively. (PUT, GET) [__GNUC__]: New macros. Use GCC's packed-structure support to do unaligned loads and stores. (PUTSWAPPED, GETSWAPPED) [__GNUC__]: Similar, but invoke a SWAP<size> macro (not defined yet) to swap the bytes of the value. (store_*, load_*): Use these macros when using GCC, depending on endianness and availability of the SWAP<size> macros. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17232 dc483132-0cff-0310-8789-dd5450dbe970
* don't always require support library when building with sun ccKen Raeburn2005-06-071-22/+25
| | | | | | | | | | | | | | | | | | | By default, a non-GCC configuration will not optimize during the build. The Solaris C compiler will always output functions defined as "inline", at least when not optimizing, even if they're never used. With recent changes on the trunk, k5_call_init_function will cause the support library to be required on Solaris by every program that includes k5-platform.h. This patch should fix that. * k5-platform.h (MAYBE_DEFINE_CALLINIT_FUNCTION) [DELAY_INITIALIZER]: New macro. If not __GNUC__, define k5_call_init_function in the expansion; otherwise, do nothing. (MAKE_INIT_FUNCTION) [DELAY_INITIALIZER]: Use it. (k5_call_init_function): Don't define function form at top level. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17230 dc483132-0cff-0310-8789-dd5450dbe970
* This patch tightens up our determination of whether we can useKen Raeburn2005-03-261-0/+57
| | | | | | | | | | | | | | | | getpw{nam,uid}_r, and using the set flags, creates macros providing a consistent API, and if possible thread safety. * configure.in: Don't check for getpwnam_r and getpwuid_r with AC_CHECK_FUNCS; use AC_CHECK_FUNC, and only set shell variables. Run stricter tests on return types and numbers of arguments, and only define the C macros if these parameters can actually be determined. * k5-platform.h (k5_getpwnam_r, k5_getpwuid_r): New macros. ticket: 2982 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17155 dc483132-0cff-0310-8789-dd5450dbe970
* shared library support for HP-UX 10Ken Raeburn2005-03-251-7/+80
| | | | | | | | | | | | | | | | | | | | | | | Our somewhat outdated HP-UX support (which was targeted at HP-UX 10, not 11) does not have support for shared library initialization and finalization functions, nor for shared library export lists. The former was causing compilation failures unless shared library support was disabled. * include/k5-platform.h: Expand on init/fini comments some more. (MAKE_FINI_FUNCTION): Add an HP-UX specific variant that defines an auxiliary function fitting the signature of HP-UX 10 library combined initializer/finalizer functions. * config/lib.in (hpux10.exports): New target, constructed similar to osf1.exports but with HP-UX 10.x linker options, no initializers, and "errno" explicitly added to the export list. * shlib.conf (*-*-hpux*): Combine PICFLAGS setting with SHLIB_EXPFLAGS and LDCOMBINE setting. Add linker option "-c hpux10.exports" to LDCOMBINE. Set SHLIB_EXPORT_FILE_DEP to hpux10.exports. Set use_linker_fini_option. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17153 dc483132-0cff-0310-8789-dd5450dbe970
* Fix build problem found testing certain combinations of optionsKen Raeburn2005-02-091-0/+2
| | | | | | | | | | * k5-platform.h (PROGRAM_EXITING) [__GNUC__ && !_WIN32 && CONSTRUCTOR_ATTR_WORKS && !DELAY_INITIALIZER]: Define as zero. ticket: 2916 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17089 dc483132-0cff-0310-8789-dd5450dbe970
* * k5-platform.h (k5_call_init_function) [DELAY_INITIALIZER] [__GNUC__]: Use aKen Raeburn2004-07-141-0/+13
| | | | | | | statement expression so any line number info printed by assertion failures is useful. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16589 dc483132-0cff-0310-8789-dd5450dbe970
* * configure.in: Test for 'inline' support.Ken Raeburn2004-07-011-17/+0
| | | | | | | * k5-platform.h (inline): Don't define here. * win-mac.h (inline): Define as __inline. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16536 dc483132-0cff-0310-8789-dd5450dbe970
* * k5-platform.h (JOIN4, JOIN4_2, JOIN3, JOIN3_2): Unused macros deleted.Ken Raeburn2004-06-251-32/+28
| | | | | | | | | | | (JOIN__2, JOIN__2_2): Renamed from JOIN2 and JOIN2_2. Insert two underscores between the tokens supplied. All uses changed to use new macros, and not use identifiers with leading underscores. ticket: 2603 status: resolved git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16521 dc483132-0cff-0310-8789-dd5450dbe970
* * k5-platform.h (MAKE_INIT_FUNCTION, CALL_INIT_FUNCTION, INITIALIZER_RAN): UseKen Raeburn2004-06-181-5/+6
| | | | | | | | the linker-driven version for Windows. The auxinit function definition needs an argument list. (MAKE_FINI_FUNCTION): Likewise. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16488 dc483132-0cff-0310-8789-dd5450dbe970
* * k5-platform.h (DELAY_INITIALIZER): Don't define.Ken Raeburn2004-04-291-20/+30
| | | | | | | | | | | | | | (CONSTRUCTOR_ATTR_WORKS, DESTRUCTOR_ATTR_WORKS): Don't define. (USE_LINKER_FINI_OPTION): Don't define. (MAYBE_DUMMY_INIT): New macro, to optionally produce a dummy initializer for the linker to reference in the case where other options indicate we don't want to use it. (MAKE_INIT_FUNCTION): Use it in some versions. Set the exported function name to have a __auxinit suffix. (MAKE_FINI_FUNCTION) [!SHARED]: Declare the function static, and do nothing to try to cause it to get invoked. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16282 dc483132-0cff-0310-8789-dd5450dbe970
* Added support for library initialization and finalization, and verificationKen Raeburn2004-04-241-2/+249
| | | | | | | | | | | | | | | | | | | | | | | | | | | that the initializer completed successfully. Delay initialization on POSIX until the first "verification" call. Currently specific to a few platforms, but should still build on others without thread support enabled. Use it to finish creating (if necessary) and destroy mutexes, and free some other storage "permanently" allocated by libraries (currently, libkrb5 cache/keytab type registries only). Change initialization of static mutexes to a two-step operation, a static "partial" initializer and a "finish_init" routine called from a thread-safe environment like library initialization is assumed to be. POSIX will use the former, Windows will use the latter, and the debug support will check that *both* have been used. Added init/fini functions to com_err, profile, krb5, and gssapi libraries. (The profile library one may need to be removed later.) The existing ones, not thread-safe, are still around. Use weak symbol support if available to figure out if the pthread library has been linked in, and avoid calling certain routines if the C library stubs are known not to exist or work. Stub declarations for thread-specific data. Minor bugfixes, whitespace changes. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16268 dc483132-0cff-0310-8789-dd5450dbe970
* * k5-platform.h (SIZE_MAX): Provide default definition if stdint.h doesn'tKen Raeburn2003-12-151-2/+36
| | | | | | | | define it. ticket: 2040 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15929 dc483132-0cff-0310-8789-dd5450dbe970
* * k5-platform.h: apply casts (unsigned char) to the assignments fromJeffrey Altman2003-12-151-16/+16
| | | | | | | | 64-bit ints to unsigned char fields to avoid warnings ticket: 1471 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15925 dc483132-0cff-0310-8789-dd5450dbe970
* Add platform-dependent 64-bit and inline-function support via new headerKen Raeburn2003-12-131-0/+136
k5-platform.h. Add 64-bit serializer support. [Not needed for ticket 1471, but needed for 2040 and annoying to check in separately.] Add to (internal for now) crypto API a function to get the mandatory checksum type associated with an enctype. New support for server-generated subkey, selected via an auth_context flag. ticket: 1471 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15908 dc483132-0cff-0310-8789-dd5450dbe970