<commit_before>/*
 * UIOMux: a conflict manager for system resources, including UIO devices.
 * Copyright (C) 2009 Renesas Technology Corp.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <pthread.h>

#include "uiomux_private.h"

/* #define DEBUG */

/* name for shm_open */
#define UIOMUX_SHM_NAME "/uiomux-shm"

/***********************************************************
 */

#ifdef DEBUG
#define debug_perror(s) perror(s)
#define debug_info(s) fprintf(stderr, s "\n")
#else
#define debug_perror(s)
#define debug_info(s)
#endif

/*
 * If \a state is non-NULL:
 *   Initialize the owners table, ie. pointers from
 *   shared_state->owners[i] to the start of the allocation
 *   table for block i.
 * If \a state is NULL:
 *   skip the initialization and just calculate the size of the owners table,
 *   ie. the sum of the sizes of the allocation tables for each block.
 * \returns The total size in bytes of the owners table.
 */
static size_t
init_owners_table (struct uiomux_state * state)
{
  struct uio * uio;
  const char * name = NULL;
  int i;
  size_t nr_pages = 0, n;
  long pagesize;
  char * o = NULL;
  pid_t * owners;

  pagesize = sysconf (_SC_PAGESIZE);

  if (state != NULL) {
    o = (char *)state + sizeof (struct uiomux_state);
    owners = (pid_t *)o;<commit_msg>Suppress a warning by compiler in init_owners_table()<commit_after>/*
 * UIOMux: a conflict manager for system resources, including UIO devices.
 * Copyright (C) 2009 Renesas Technology Corp.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <pthread.h>

#include "uiomux_private.h"

/* #define DEBUG */

/* name for shm_open */
#define UIOMUX_SHM_NAME "/uiomux-shm"

/***********************************************************
 */

#ifdef DEBUG
#define debug_perror(s) perror(s)
#define debug_info(s) fprintf(stderr, s "\n")
#else
#define debug_perror(s)
#define debug_info(s)
#endif

/*
 * If \a state is non-NULL:
 *   Initialize the owners table, ie. pointers from
 *   shared_state->owners[i] to the start of the allocation
 *   table for block i.
 * If \a state is NULL:
 *   skip the initialization and just calculate the size of the owners table,
 *   ie. the sum of the sizes of the allocation tables for each block.
 * \returns The total size in bytes of the owners table.
 */
static size_t
init_owners_table (struct uiomux_state * state)
{
  struct uio * uio;
  const char * name = NULL;
  int i;
  size_t nr_pages = 0, n;
  long pagesize;
  char * o = NULL;
  pid_t * owners = NULL;

  pagesize = sysconf (_SC_PAGESIZE);

  if (state != NULL) {
    o = (char *)state + sizeof (struct uiomux_state);
    owners = (pid_t *)o;
{'fraction_non_alphanumeric': 0.11982082866741321, 'fraction_numerical': 0.00761478163493841, 'mean_word_length': 3.8808743169398907, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '2720080', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1367, 'n_words': 578}