-
+ 9CB4E6A599501CCB7615C4DA88439D29C483B03D85BA4FC5A02C2B2FBF2920AEDE4E99F0438D86802183B05F3A113CA597A676B18D373F2D5E39D9D6F65553B2
smg_comms/mpi/include/util.h
(0 . 0)(1 . 86)
2673 /* util.h
2674 * Modified by No Such Labs. (C) 2015. See README.
2675 *
2676 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
2677 * SHA256(gnupg-1.4.10.tar.gz):
2678 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
2679 * (C) 1994-2005 Free Software Foundation, Inc.
2680 *
2681 * This program is free software: you can redistribute it and/or modify
2682 * it under the terms of the GNU General Public License as published by
2683 * the Free Software Foundation, either version 3 of the License, or
2684 * (at your option) any later version.
2685 *
2686 * This program is distributed in the hope that it will be useful,
2687 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2688 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2689 * GNU General Public License for more details.
2690 *
2691 * You should have received a copy of the GNU General Public License
2692 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2693 */
2694
2695 #ifndef G10_UTIL_H
2696 #define G10_UTIL_H
2697
2698 #if defined (_WIN32) || defined (__CYGWIN32__)
2699 #include <stdarg.h>
2700 #endif
2701
2702 #include "types.h"
2703 #include "types.h"
2704 #include "mpi.h"
2705
2706 #define log_hexdump printf
2707 #define log_bug printf
2708 #define log_bug0 printf
2709 #define log_fatal printf
2710 #define log_error printf
2711 #define log_info printf
2712 #define log_warning printf
2713 #define log_debug printf
2714
2715 #define g10_log_print_prefix printf
2716
2717
2718 #ifndef HAVE_MEMMOVE
2719 #define memmove(d, s, n) bcopy((s), (d), (n))
2720 #endif
2721
2722
2723 /**** other missing stuff ****/
2724 #ifndef HAVE_ATEXIT /* For SunOS */
2725 #define atexit(a) (on_exit((a),0))
2726 #endif
2727
2728 #ifndef HAVE_RAISE
2729 #define raise(a) kill(getpid(), (a))
2730 #endif
2731
2732 /******** some macros ************/
2733 #ifndef STR
2734 #define STR(v) #v
2735 #endif
2736 #define STR2(v) STR(v)
2737 #define DIM(v) (sizeof(v)/sizeof((v)[0]))
2738 #define DIMof(type,member) DIM(((type *)0)->member)
2739
2740 #define wipememory2(_ptr,_set,_len) do { volatile char *_vptr=(volatile char *)(_ptr); size_t _vlen=(_len); while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } } while(0)
2741 #define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
2742
2743 /*-- macros to replace ctype ones and avoid locale problems --*/
2744 #define spacep(p) (*(p) == ' ' || *(p) == '\t')
2745 #define digitp(p) (*(p) >= '0' && *(p) <= '9')
2746 #define hexdigitp(a) (digitp (a) \
2747 || (*(a) >= 'A' && *(a) <= 'F') \
2748 || (*(a) >= 'a' && *(a) <= 'f'))
2749 /* the atoi macros assume that the buffer has only valid digits */
2750 #define atoi_1(p) (*(p) - '0' )
2751 #define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
2752 #define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2))
2753 #define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
2754 *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
2755 #define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
2756
2757
2758 #endif /*G10_UTIL_H*/