请告诉我,在XCode 4.3中stdlib.h的位置是什么?
我正在编写一个简单的内核模块,它可以注册一个中断并处理它.但是,当我尝试通过调用request_irq函数来注册中断时,它返回错误代码-22:
错误:无法请求IRQ 30 - 代码-22,EIO 5,EINVAL 22
我相信,这个错误代码等于EINVAL(无效参数)
请告诉我,我做错了什么.这是一个模块:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/irq.h>
#include <linux/io.h>
#include <linux/irqdomain.h>
#include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <asm/exception.h>
#include <asm/mach/irq.h>
void int068_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
printk("Interrupt should be handled there\n");
}
static int __init
clcdint_init(void)
{
unsigned int irq;
unsigned int irqflags;
int ret;
irq=68;
irqflags=IRQF_SHARED | IRQF_NO_SUSPEND;
ret = request_irq(irq, int068_interrupt,
irqflags, "clcdint-int068", NULL);
if (ret!=0) {
printk("ERROR: Cannot request IRQ %d", irq);
printk(" - code …Run Code Online (Sandbox Code Playgroud) 在内核模块中,我需要通过向物理内存的地址写入"零"来处理中断.
首先,我应该通过像"mmap"这样的函数来分配内存,但对于内核模块; 例如,ioremap.
static irqreturn_t int068_interrupt(int irq, void *dev_id)
{
unsigned int *p;
unsigned int address;
unsigned int memsize;
address = 0x12345678;
memsize = 1024;
p = ioremap(address, memsize);
p[0]=0;
printk("Interrupt was handled\n");
return IRQ_HANDLED;
}
Run Code Online (Sandbox Code Playgroud)
但是,当中断到来并且中断处理程序开始处理它时内核崩溃(内核BUG为mm/vmalloc.c:numberofline)
我使用ioremap似乎有问题,或者我应该使用另一个"mmap的内核替代品"
请告诉我,如何解决这个问题?
美好的一天.我想创建两个(几乎相同)模块 - 每个模块使用netlink套接字并回复来自用户空间程序的传入消息.
在初始化第一个模块期间,它成功执行以下命令:
netlink kernel create(&init_net, NETLINK_USER, &cfg)
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用相同的参数启动第二个模块,则相同的命令将导致错误.
我认为发生此错误是因为两个模块的NETLINK_USER值相同 - 这就是为什么我无法为同一个netlink用户创建第二个套接字连接.但是,如果我尝试将NETLINK_USER值设置为32,则会出现内核错误.任何其他值 - 错误.
请告诉我,我需要做什么,以便同时使用两个内核模块?
请告诉我,为什么我的简单应用程序无法mmap一小块内存?
而且,为什么这样一个特定的边界 - 257UL?
// #define MAP_SIZE 256UL or below - fail
// #define MAP_SIZE 257UL - ok
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/mman.h>
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
int main(int argc, char **argv) {
int fd;
void *map_base, *virt_addr; …Run Code Online (Sandbox Code Playgroud) 我必须在代码中定义一个大型数组(查找表).它包含256个元素,占用近1个电脑屏幕.
有两个函数正在使用此数组.我想在函数下定义这个数组,所以我可以在开发过程中非常快速地访问它们.
但是如果我尝试在一个文件中执行它,编译器将在函数周围给出"未声明的标识符"错误 - 因为它们使用数组.
所以,我必须将函数和数组放在单独的文件中.
这是我的程序的结构:
main.cpp:
#include "lookup.h"
...uses two functions...
Run Code Online (Sandbox Code Playgroud)
-
lookup.h:
#ifndef SubMaster_lookup_h
#define SubMaster_lookup_h
void func1(void);
void func2(void);
char LookupTable[][3]={ "00", "01", "02" "03", "04", "05", "06", "07", "08", "09",
"0a", "0b", "0c", "0d", "0e", "0f", "00", "01", "02" "03", "04", "05", "06", "07",
"08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", and so on...}
Run Code Online (Sandbox Code Playgroud)
-
lookup.cpp:
#include "lookup.h"
void func1() {
...body of func1...
}
void func2() {
...body of …Run Code Online (Sandbox Code Playgroud) 请告诉我,是否可以使用malloc来增加现有阵列的大小?(没有分配新的数组,然后做memcpy)如果是,怎么样?
我在刷新内部数据时遇到问题JComboBox.
有一个按钮" Create" ActionListener,它将项目添加到JComboBox.
但是这些变化并没有反映在GUI中:我仍然没有看到新添加的项目.
repaint() 没有帮助.
更新:这是一个(几乎)完整的GUI代码:
public class Main extends JFrame implements ActionListener
{
static Connection conn;
static PreparedStatement ps = null;
static ResultSet res;
static Statement sta;
private final static int ITERATION_NUMBER = 1000;
public void GUI () throws SQLException {
setBounds(0, 0, 320, 240);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
close(ps);
close(res);
close(conn);
System.exit(0);
}
});
setMinimumSize(new Dimension(320, 240));
setResizable(false);
this.setTitle("Accounts");
JPanel panel = new JPanel();
GridLayout2 GL = new …Run Code Online (Sandbox Code Playgroud) 请告诉我,如何使 JTable 列包含 JTextAreas,以便当用户键入大量文本时单元格的高度会增加,并且我们可以看到不止一行(单元格扩展;因此,行也会扩展)
测试应该返回真:如果第一部分为真,第二部分为假。
试图做这样的事情:
f_test :- f(x), % 1st part
f(y) is false. % 2nd part
Run Code Online (Sandbox Code Playgroud)
但它给了我一个错误:
ERROR: is/2: Arithmetic: `false/0' is not a function.
Run Code Online (Sandbox Code Playgroud)
请告诉我,如何正确地做到这一点?