misc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. Copyright (c) 1994-1997, 2001-2002 MEDICAL RESEARCH COUNCIL
  3. All rights reserved
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. 1 Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. 2 Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. 3 Neither the name of the MEDICAL RESEARCH COUNCIL, THE LABORATORY OF
  12. MOLECULAR BIOLOGY nor the names of its contributors may be used to endorse or
  13. promote products derived from this software without specific prior written
  14. permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  19. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  22. ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. /*
  27. Copyright (c) 2003-2013 Genome Research Ltd.
  28. Author: James Bonfield <jkb@sanger.ac.uk>
  29. Redistribution and use in source and binary forms, with or without
  30. modification, are permitted provided that the following conditions are met:
  31. 1. Redistributions of source code must retain the above copyright notice,
  32. this list of conditions and the following disclaimer.
  33. 2. Redistributions in binary form must reproduce the above copyright notice,
  34. this list of conditions and the following disclaimer in the documentation
  35. and/or other materials provided with the distribution.
  36. 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
  37. Institute nor the names of its contributors may be used to endorse or promote
  38. products derived from this software without specific prior written permission.
  39. THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND
  40. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  41. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  42. DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE
  43. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  44. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  45. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  46. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  47. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  48. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49. */
  50. #ifndef _misc_h
  51. #define _misc_h
  52. #include "cram/os.h"
  53. #include <stdio.h>
  54. #include <stdarg.h> /* varargs needed for v*printf() prototypes */
  55. #include <sys/types.h>
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59. /*
  60. * This informs gcc that crash() doesn't return, so it doesn't need to
  61. * concern itself that code paths going via crash could mean some variables
  62. * being undefined and then issuing uninitialised variable warnings.
  63. * This particularly affected convert.
  64. */
  65. #ifdef __GNUC__
  66. # define __NORETURN__ __attribute__ ((__noreturn__))
  67. #else
  68. # define __NORETURN__
  69. #endif
  70. /*
  71. * Used for printf style argument checking. We can request a function such
  72. * as vTcl_SetResult does argument checking, avoiding bugs with using
  73. * %d and passing in a 64-bit record.
  74. */
  75. #ifdef __GNUC__
  76. # define __PRINTF_FORMAT__(a,b) __attribute__ ((format (printf, a, b)))
  77. #else
  78. # define __PRINTF_FORMAT__(a,b)
  79. #endif
  80. extern int is_directory(char * fn);
  81. extern int is_file(char * fn);
  82. extern int file_size(char * fn);
  83. #define MIN(A,B) ( ( (A) < (B) ) ? (A) : (B) )
  84. #define MAX(A,B) ( ( (A) > (B) ) ? (A) : (B) )
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif /*_misc_h*/