Moved SMP macros to smp.h

This commit is contained in:
Florian Pose
2026-07-15 13:41:25 +02:00
parent ef425519db
commit b4217e93b0
5 changed files with 63 additions and 29 deletions
+1
View File
@@ -67,6 +67,7 @@ noinst_HEADERS = \
sdo_request.c sdo_request.h \
slave.c slave.h \
slave_config.c slave_config.h \
smp.h \
soe_errors.c \
soe_request.c soe_request.h \
sync.c sync.h \
+1
View File
@@ -32,6 +32,7 @@
#ifdef EC_EOE
#include "ethernet.h"
#endif
#include "smp.h"
#include "fsm_master.h"
#include "fsm_foe.h"
+4 -29
View File
@@ -24,14 +24,12 @@
/****************************************************************************/
#ifndef __EC_MASTER_GLOBALS_H__
#define __EC_MASTER_GLOBALS_H__
#ifndef MASTER_GLOBALS_H_
#define MASTER_GLOBALS_H_
#include "../globals.h"
#include "../include/ecrt.h"
#include <linux/version.h>
/*****************************************************************************
* EtherCAT master
****************************************************************************/
@@ -173,8 +171,7 @@ typedef struct {
*/
typedef enum {
EC_DC_32, /**< 32 bit. */
EC_DC_64 /*< 64 bit for system time, system time offset and
port 0 receive time. */
EC_DC_64 /*< 64 bit for system time, time offset and port receive time. */
} ec_slave_dc_range_t;
/** EtherCAT slave sync signal configuration.
@@ -254,28 +251,6 @@ extern const char *ec_device_names[2]; // only main and backup!
/****************************************************************************/
/* Define SMP macros on kernel versions where they did not exist yet.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 47)
#define smp_store_release(p, v) \
do { \
smp_mb(); \
ACCESS_ONCE(*p) = (v); \
} while (0)
#define smp_load_acquire(p) \
({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
smp_mb(); \
___p1; \
})
#endif
/****************************************************************************/
extern char *ec_master_version_str;
/****************************************************************************/
@@ -335,4 +310,4 @@ typedef struct ec_slave ec_slave_t; /**< \see ec_slave. */
/****************************************************************************/
#endif
#endif // MASTER_GLOBALS_H_
+1
View File
@@ -43,6 +43,7 @@
#include "slave_config.h"
#include "device.h"
#include "datagram.h"
#include "smp.h"
#ifdef EC_EOE
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+56
View File
@@ -0,0 +1,56 @@
/*****************************************************************************
*
* Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH
*
* This file is part of the IgH EtherCAT master.
*
* The file is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; version 2.1 of the License.
*
* This file 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this file. If not, see <http://www.gnu.org/licenses/>.
*
****************************************************************************/
/** \file
* Definitions of Kernel SMP macros.
*/
/****************************************************************************/
#ifndef MASTER_SMP_H_
#define MASTER_SMP_H_
#include <linux/version.h>
/****************************************************************************/
/* Define SMP macros on kernel versions where they did not exist yet.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 47)
#define smp_store_release(p, v) \
do { \
smp_mb(); \
ACCESS_ONCE(*p) = (v); \
} while (0)
#define smp_load_acquire(p) \
({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
smp_mb(); \
___p1; \
})
#endif
/****************************************************************************/
#endif // MASTER_SMP_H_