kpmpgsmkii/shared/macros.h
2022-04-04 20:20:09 -05:00

55 lines
1.5 KiB
C

/*
* Kangaroo Punch MultiPlayer Game Server Mark II
* Copyright (C) 2020-2021 Scott Duensing
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef MACROS_H
#define MACROS_H
#include <stdio.h>
// Should be after system headers in this file.
#define MEMORY_CHECK_ENABLED
#include "memory.h"
// Now our headers.
#include "log.h"
#include "util.h"
// Debug helpers.
#define BEGIN logWrite("BEGIN - %s @ %s (%d)\n", __FILE__, __func__, __LINE__);
#define END logWrite("END - %s @ %s (%d)\n", __FILE__, __func__, __LINE__);
// Allocation helpers.
#define NEW(t,v) (v)=(t*)malloc(sizeof(t))
#define DEL(v) {free(v); v=NULL;}
// Some helper defines.
#define DIVISIBLE_BY_EIGHT(x) ((((x) >> 3) << 3) == (x))
#define HIGH_BYTE(b) ((uint8_t)(((b) & 0xFF00) >> 8))
#define LOW_BYTE(b) ((uint8_t)((b) & 0x00FF))
#define SUCCESS 1
#define FAIL 0
#define MAX_PATH 1024
#endif // MACROS_H