What is a REFERENCE_PARAM?

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
gerrykurz
XCore Addict
Posts: 204
Joined: Sun Jun 01, 2014 10:25 pm

What is a REFERENCE_PARAM?

Post by gerrykurz »

These are used extensively in the ethernet code for example:

// Copyright (c) 2011, XMOS Ltd., All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>

#ifndef __mii_filter_h__
#define __mii_filter_h__
#include "mii_full.h"
#include "mii_queue.h"
#include "mii_malloc.h"

//! This define is the last bit in the filter bitfield, and is set when the
//! system has to forward the packet to the other ethernet ports
#define MII_FILTER_FORWARD_TO_OTHER_PORTS (0x80000000)

void ethernet_filter(const char mac[], streaming chanend c[NUM_ETHERNET_PORTS]);

#if ETHERNET_COUNT_PACKETS
void ethernet_get_filter_counts(REFERENCE_PARAM(unsigned,address),
REFERENCE_PARAM(unsigned,filter),
REFERENCE_PARAM(unsigned,length),
REFERENCE_PARAM(unsigned,crc));
#endif

#endif // __mii_filter_h__
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

REFERENCE_PARAM is a macro in the header xccompat.h. Taking REFERENCE_PARAM(unsigned,filter) as an example, this will expand to:

Code: Select all

unsigned &filter
in xC and

Code: Select all

unsigned *filter
in C.

The reason for the macro is to make it easier to write function prototypes in header files that can be called from both C and xC.