123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- /*
- * Copyright (C) 2020 Weber Yann
- *
- * This file is part of pyrpn.
- *
- * pyrpn 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
- * any later version.
- *
- * pyrpn 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 pyrpn. If not, see <http://www.gnu.org/licenses/>.
- */
- #ifndef __rpn_lib__h__
- #define __rpn_lib__h__
-
- #include "config.h"
-
- #include <sys/mman.h>
-
- /**@defgroup rpn_lib RPNlib
- * @brief Precompiled x86_64 assembly operations
- * @ingroup rpn_compile
- */
-
- /**@file rpn_lib.h
- * @brief "Import" symbols defined in @ref rpn_lib.asm using @ref CODE_PART macro.
- *
- * For each symbol (piece of compiled assembly code) @ref CODE_PART defines :
- * - void *NAME : the pointer on compiled code
- * - unsigned long NAME_sz : the size of the code portion
- *
- * @see rpn_lib.asm
- * @ingroup rpn_lib
- */
- /**@file rpn_lib.asm
- * @brief x86_64 RPN expression operations implementations
- *
- * Exported symbols are found in @ref rpn_lib.h
- * @ingroup rpn_lib
- */
-
-
- /**@brief Code part size macro */
- #define CODE_SZ(NAME) NAME ## _sz
-
- /**@brief macro to declare a code part and associated size */
- #define CODE_PART(NAME) const extern void* NAME; \
- /**@brief Cord part size */\
- extern const unsigned long NAME ## _sz
-
- /**@brief Define the type of value manipulated by RPN expressions
- *
- * Use it for stack and arguments items
- * @todo use it */
- typedef unsigned long int rpn_value_t;
-
- /**@brief Small alias for PyLong_FromUnsignedLong */
- #define PyLong_FromRpnValue_t PyLong_FromUnsignedLong
- /**@brief Small alias for PyLong_AsUnsignedLong */
- #define PyLong_AsRpnValue_t PyLong_AsUnsignedLong
-
- /**@brief Function heading code
- *
- * - stack frame creation
- * - argument processing
- * - etc.
- * @ingroup rpn_lib */
- CODE_PART(rpn_exec);
- /**@brief Function ends and ret code
- *
- * - pop and return head of stack value
- * - stack frame deletion
- * @ingroup rpn_lib */
- CODE_PART(rpn_exec_ret);
- /**@brief Constant value pushing symbol
- * @note except a value to be set
- * @ingroup rpn_lib */
- CODE_PART(rpn_value);
- /**@brief Argument pushing symbol
- * @note except a value to be set
- * @ingroup rpn_lib */
- CODE_PART(rpn_arg);
- /**@brief Addition symbol
- * @ingroup rpn_lib */
- CODE_PART(rpn_add);
- /**@brief Substraction symbol
- * @ingroup rpn_lib */
- CODE_PART(rpn_sub);
- /**@brief Division symbol
- * @ingroup rpn_lib */
- CODE_PART(rpn_div);
- /**@brief Multiplication symbol
- * @ingroup rpn_lib */
- CODE_PART(rpn_mul);
- /**@brief Modulo symbol
- * @ingroup rpn_lib */
- CODE_PART(rpn_mod);
- /**@brief Left shift symbol
- * @ingroup rpn_lib */
- CODE_PART(rpn_shl);
- /**@brief Right shift symbol
- * @ingroup rpn_lib */
- CODE_PART(rpn_shr);
- /**@brief Value exchange symbol
- * @ingroup rpn_lib */
- CODE_PART(rpn_xchg);
- /**@brief Head of stack duplication
- * @ingroup rpn_lib */
- CODE_PART(rpn_dup);
- /**@brief Arithmetic negation
- * @ingroup rpn_lib */
- CODE_PART(rpn_neg);
- /**@brief Binary not
- * @ingroup rpn_lib */
- CODE_PART(rpn_not);
- /**@brief Binary and
- * @ingroup rpn_lib */
- CODE_PART(rpn_and);
- /**@brief Binary or
- * @ingroup rpn_lib */
- CODE_PART(rpn_or);
- /**@brief Binary xor
- * @ingroup rpn_lib */
- CODE_PART(rpn_xor);
- /**@brief Pop head of stack
- * @ingroup rpn_lib */
- CODE_PART(rpn_pop_op);
-
- #endif
|