2016-09-13 18:54:26 -07:00
|
|
|
#ifndef COMMON_H
|
|
|
|
#define COMMON_H
|
|
|
|
|
2016-09-23 22:53:58 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2016-09-18 18:06:42 -07:00
|
|
|
#include <string.h>
|
2017-04-19 02:43:33 -07:00
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
|
|
|
#define __STDC_FORMAT_MACROS
|
|
|
|
#endif
|
2016-09-13 18:54:26 -07:00
|
|
|
#include <errno.h>
|
2016-10-29 15:22:33 -07:00
|
|
|
#include <inttypes.h>
|
2016-11-22 17:04:24 -08:00
|
|
|
#ifndef _WIN32
|
2016-10-29 19:25:43 -07:00
|
|
|
#include <execinfo.h>
|
2016-11-22 17:04:24 -08:00
|
|
|
#endif
|
2016-09-13 18:54:26 -07:00
|
|
|
|
2017-03-05 02:05:02 -08:00
|
|
|
#ifdef __cplusplus
|
2017-04-07 12:32:12 -07:00
|
|
|
#include <functional>
|
2017-03-05 02:05:02 -08:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
2016-12-08 20:57:08 -08:00
|
|
|
#include "sha256.h"
|
2017-03-05 02:05:02 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2016-11-06 17:31:14 -08:00
|
|
|
|
2017-07-31 21:04:15 -07:00
|
|
|
#include "arrow/util/macros.h"
|
2017-12-26 16:22:04 -08:00
|
|
|
#include "plasma/common.h"
|
|
|
|
#include "ray/id.h"
|
2018-02-28 15:13:00 -08:00
|
|
|
#include "ray/util/logging.h"
|
2017-07-31 21:04:15 -07:00
|
|
|
|
2017-11-08 11:10:38 -08:00
|
|
|
#include "state/ray_config.h"
|
2017-03-17 17:03:58 -07:00
|
|
|
|
2016-12-08 20:57:08 -08:00
|
|
|
/** Definitions for Ray logging levels. */
|
2016-11-15 20:33:29 -08:00
|
|
|
#define RAY_COMMON_DEBUG 0
|
|
|
|
#define RAY_COMMON_INFO 1
|
|
|
|
#define RAY_COMMON_WARNING 2
|
|
|
|
#define RAY_COMMON_ERROR 3
|
|
|
|
#define RAY_COMMON_FATAL 4
|
|
|
|
|
2016-12-08 20:57:08 -08:00
|
|
|
/**
|
|
|
|
* RAY_COMMON_LOG_LEVEL should be defined to one of the above logging level
|
|
|
|
* integer values. Any logging statement in the code with a logging level
|
|
|
|
* greater than or equal to RAY_COMMON_LOG_LEVEL will be outputted to stderr.
|
|
|
|
* The default logging level is INFO. */
|
2016-11-15 20:33:29 -08:00
|
|
|
#ifndef RAY_COMMON_LOG_LEVEL
|
|
|
|
#define RAY_COMMON_LOG_LEVEL RAY_COMMON_INFO
|
|
|
|
#endif
|
|
|
|
|
2016-10-31 15:00:15 -07:00
|
|
|
/* These are exit codes for common errors that can occur in Ray components. */
|
|
|
|
#define EXIT_COULD_NOT_BIND_PORT -2
|
|
|
|
|
2016-10-29 15:22:33 -07:00
|
|
|
/** This macro indicates that this pointer owns the data it is pointing to
|
|
|
|
* and is responsible for freeing it. */
|
|
|
|
#define OWNER
|
|
|
|
|
2017-04-24 18:10:21 -07:00
|
|
|
/** The worker ID is the ID of a worker or driver. */
|
2017-12-26 16:22:04 -08:00
|
|
|
typedef ray::UniqueID WorkerID;
|
2017-04-24 18:10:21 -07:00
|
|
|
|
2017-12-26 16:22:04 -08:00
|
|
|
typedef ray::UniqueID DBClientID;
|
2017-11-10 11:29:24 -08:00
|
|
|
|
2016-12-01 02:15:21 -08:00
|
|
|
#define MAX(x, y) ((x) >= (y) ? (x) : (y))
|
|
|
|
#define MIN(x, y) ((x) <= (y) ? (x) : (y))
|
|
|
|
|
2016-12-08 20:57:08 -08:00
|
|
|
/** Definitions for computing hash digests. */
|
|
|
|
#define DIGEST_SIZE SHA256_BLOCK_SIZE
|
|
|
|
|
|
|
|
extern const unsigned char NIL_DIGEST[DIGEST_SIZE];
|
|
|
|
|
2017-06-16 12:11:01 -07:00
|
|
|
/**
|
|
|
|
* Return the current time in milliseconds since the Unix epoch.
|
|
|
|
*
|
|
|
|
* @return The number of milliseconds since the Unix epoch.
|
|
|
|
*/
|
|
|
|
int64_t current_time_ms();
|
|
|
|
|
2016-09-13 18:54:26 -07:00
|
|
|
#endif
|