<commit_before>/* Copyright (c) 2013, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#include <odp_config_internal.h>
#include <odp/api/debug.h>
#include <odp/api/std_types.h>
#include <odp/api/shared_memory.h>
#include <_ishm_internal.h>
#include <string.h>

ODP_STATIC_ASSERT(ODP_CONFIG_SHM_BLOCKS >= ODP_CONFIG_POOLS,
		  "ODP_CONFIG_SHM_BLOCKS < ODP_CONFIG_POOLS");

static inline uint32_t from_handle(odp_shm_t shm)
{
	return _odp_typeval(shm) - 1;
}

static inline odp_shm_t to_handle(uint32_t index)
{
	return _odp_cast_scalar(odp_shm_t, index + 1);
}

int odp_shm_capability(odp_shm_capability_t *capa)
{
	memset(capa, 0, sizeof(odp_shm_capability_t));

	capa->max_blocks = ODP_CONFIG_SHM_BLOCKS;
	capa->max_size = 0;
	capa->max_align = 0;

	return 0;
}

odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
			  uint32_t flags)
{
	int block_index;
	int flgs = 0; /* internal ishm flags */

	/* set internal ishm flags according to API flags: */
	flgs |= (flags & ODP_SHM_PROC) ? _ODP_ISHM_EXPORT : 0;

	/* all mem reserved through this interface is requested to be locked: */
	flgs |= (flags & _ODP_ISHM_LOCK);

	block_index = _odp_ishm_reserve(name, size, -1, align, flgs, flags);
	if (block_index >= 0)<commit_msg>linux-gen: shm: new ODP_SHM_SINGLE_VA flag implementation<commit_after>/* Copyright (c) 2013, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#include <odp_config_internal.h>
#include <odp/api/debug.h>
#include <odp/api/std_types.h>
#include <odp/api/shared_memory.h>
#include <_ishm_internal.h>
#include <string.h>

ODP_STATIC_ASSERT(ODP_CONFIG_SHM_BLOCKS >= ODP_CONFIG_POOLS,
		  "ODP_CONFIG_SHM_BLOCKS < ODP_CONFIG_POOLS");

static inline uint32_t from_handle(odp_shm_t shm)
{
	return _odp_typeval(shm) - 1;
}

static inline odp_shm_t to_handle(uint32_t index)
{
	return _odp_cast_scalar(odp_shm_t, index + 1);
}

int odp_shm_capability(odp_shm_capability_t *capa)
{
	memset(capa, 0, sizeof(odp_shm_capability_t));

	capa->max_blocks = ODP_CONFIG_SHM_BLOCKS;
	capa->max_size = 0;
	capa->max_align = 0;

	return 0;
}

odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
			  uint32_t flags)
{
	int block_index;
	int flgs = 0; /* internal ishm flags */

	/* set internal ishm flags according to API flags: */
	flgs |= (flags & ODP_SHM_PROC) ? _ODP_ISHM_EXPORT : 0;
	flgs |= (flags & ODP_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0;

	/* all mem reserved through this interface is requested to be locked: */
	flgs |= (flags & _ODP_ISHM_LOCK);

	block_index = _odp_ishm_reserve(name, size, -1, align, flgs, flags);
	if (block_index >= 0)
{'fraction_non_alphanumeric': 0.11701337295690936, 'fraction_numerical': 0.018945022288261514, 'mean_word_length': 4.9448123620309055, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4543547', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1140, 'n_words': 235}