<commit_before>/*
 * Copyright (C) 2014-2015 Freie Universität Berlin
 *
 * This file is subject to the terms and conditions of the GNU Lesser General
 * Public License v2.1. See the file LICENSE in the top level directory for more
 * details.
 */

/**
 * @ingroup     cpu_cortexm_common
 * @{
 *
 * @file
 * @brief       Implementation of the kernels irq interface
 *
 * @author      <NAME> <<EMAIL>>
 *
 * @}
 */


#ifndef _IRQ_ARCH_H
#define _IRQ_ARCH_H

#include <stdint.h>
#include "cpu_conf.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief Disable all maskable interrupts
 */
static inline __attribute__((always_inline)) unsigned int irq_disable(void)
{
    uint32_t mask = __get_PRIMASK();
    __disable_irq();
    return mask;
}

/**
 * @brief Enable all maskable interrupts
 */
static inline __attribute__((always_inline)) __attribute__((used)) unsigned int
irq_enable(void)
{
    __enable_irq();
    return __get_PRIMASK();
}

/**
 * @brief Restore the state of the IRQ flags
 */
static inline __attribute__((always_inline)) void irq_restore(
    unsigned int state)
{
    __set_PRIMASK(state);
}

/**
 * @brief See if the current context is inside an ISR
 */
static inline __attribute__((always_inline)) int irq_is_in(void)
{
    return (__get_IPSR() & 0xFF);
}

#ifdef __cplusplus
}
#endif

#endif /* _IRQ_ARCH_H */
/** @} */<commit_msg>cpu/cortexm_common/irq_arch: fix irq_enable return type<commit_after>/*
 * Copyright (C) 2014-2015 Freie Universität Berlin
 *
 * This file is subject to the terms and conditions of the GNU Lesser General
 * Public License v2.1. See the file LICENSE in the top level directory for more
 * details.
 */

/**
 * @ingroup     cpu_cortexm_common
 * @{
 *
 * @file
 * @brief       Implementation of the kernels irq interface
 *
 * @author      <NAME> <<EMAIL>>
 *
 * @}
 */


#ifndef IRQ_ARCH_H
#define IRQ_ARCH_H

#include <stdint.h>
#include "cpu_conf.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief Disable all maskable interrupts
 */
static inline __attribute__((always_inline)) unsigned int irq_disable(void)
{
    uint32_t mask = __get_PRIMASK();

    __disable_irq();
    return mask;
}

/**
 * @brief Enable all maskable interrupts
 */
static inline __attribute__((always_inline)) __attribute__((used)) unsigned int
irq_enable(void)
{
    unsigned result = __get_PRIMASK();

    __enable_irq();
    return result;
}

/**
 * @brief Restore the state of the IRQ flags
 */
static inline __attribute__((always_inline)) void irq_restore(
    unsigned int state)
{
    __set_PRIMASK(state);
}

/**
 * @brief See if the current context is inside an ISR
 */
static inline __attribute__((always_inline)) int irq_is_in(void)
{
    return (__get_IPSR() & 0xFF);
}

#ifdef __cplusplus
}
#endif

#endif /* IRQ_ARCH_H */
/** @} */
{'fraction_non_alphanumeric': 0.11876569788302835, 'fraction_numerical': 0.009329027628274129, 'mean_word_length': 3.749574105621806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '7643389', 'n_tokens_mistral': 952, 'n_tokens_neox': 937, 'n_words': 275}