zmq_utils.h 2.48 KB
Newer Older
1
/*
2
    Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
3 4 5 6

    This file is part of 0MQ.

    0MQ is free software; you can redistribute it and/or modify it under
7
    the terms of the GNU Lesser General Public License as published by
8 9 10 11 12 13
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    0MQ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU Lesser General Public License for more details.
15

16
    You should have received a copy of the GNU Lesser General Public License
17 18 19
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

20 21 22
#ifndef __ZMQ_UTILS_H_INCLUDED__
#define __ZMQ_UTILS_H_INCLUDED__

23 24 25 26 27
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>

Martin Sustrik's avatar
Martin Sustrik committed
28 29 30 31
#ifdef __cplusplus
extern "C" {
#endif

32
/*  Handle DSO symbol visibility                                             */
33
#if defined _WIN32
34 35 36
#   if defined ZMQ_STATIC
#       define ZMQ_EXPORT
#   elif defined DLL_EXPORT
37 38 39 40 41
#       define ZMQ_EXPORT __declspec(dllexport)
#   else
#       define ZMQ_EXPORT __declspec(dllimport)
#   endif
#else
42 43 44 45 46 47
#   if defined __SUNPRO_C  || defined __SUNPRO_CC
#       define ZMQ_EXPORT __global
#   elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER
#       define ZMQ_EXPORT __attribute__ ((visibility("default")))
#   else
#       define ZMQ_EXPORT
48
#   endif
49
#endif
50

51 52
typedef void (zmq_thread_fn) (void*);

53 54 55 56
/*  Helper functions are used by perf tests so that they don't have to care   */
/*  about minutiae of time-related functions on different OS platforms.       */

/*  Starts the stopwatch. Returns the handle to the watch.                    */
57
ZMQ_EXPORT void *zmq_stopwatch_start (void);
58 59 60

/*  Stops the stopwatch. Returns the number of microseconds elapsed since     */
/*  the stopwatch was started.                                                */
61
ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_);
62 63

/*  Sleeps for specified number of seconds.                                   */
64 65
ZMQ_EXPORT void zmq_sleep (int seconds_);

66
/* Start a thread. Returns a handle to the thread.                            */
67
ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn* func, void* arg);
68 69

/* Wait for thread to complete then free up resources.                        */
70
ZMQ_EXPORT void zmq_threadclose (void* thread);
71

72
#undef ZMQ_EXPORT
73

Martin Sustrik's avatar
Martin Sustrik committed
74 75 76 77
#ifdef __cplusplus
}
#endif

78
#endif